《PHP實例:php面向?qū)ο笾瓷涔δ芘c用法分析》要點:
本文介紹了PHP實例:php面向?qū)ο笾瓷涔δ芘c用法分析,希望對您有用。如果有疑問,可以聯(lián)系我們。
本文實例講述了php面向?qū)ο笾瓷涔δ芘c用法.分享給大家供大家參考,具體如下:PHP教程
個人對反射定義的理解:PHP教程
首先得說說什么叫反射.對于一個新手來說,反射這個概念常常給人一種似懂非懂的 感覺,不知道該如何下手操作.PHP教程
反射是指:指在PHP運行狀態(tài)中,擴展分析PHP程序,導出或提取出關(guān)于類、方法、屬性、參數(shù)等的詳細信息,同時也包括注釋.這種動態(tài)獲取的信息以及動態(tài)調(diào)用對象的方法 的功能稱為反射API.反射是操縱面向?qū)ο蠓缎椭性P偷腁PI,其功能十分強大,可幫助我們構(gòu)建復雜,可擴展的應(yīng)用.(注意:php中這種反向操作,實在PHP5之后才完全具備)PHP教程
下面在此我用實例進行說明:PHP教程
class test{ private $A; public $B; protected $C; public function test(){ return "this is a test function"; } } //實例化一個反射類ReflectionClass $obj=new ReflectionClass('test'); echo $obj."<br>"; //實例化test類,并訪問其test方法 $obj2=$obj->newInstance(); echo $obj2->test();
個人實例返回結(jié)果:PHP教程
/** * xxx.php * ============================================== * Copy right 2012-2015 * ---------------------------------------------- * This is not a free software, without any authorization is not allowed to use and spread. * ============================================== * @Author:YeXianMing * @Email:LangWaiShiGe@hotmail.com * @Version:zend studio10.6.2 php5.4.38 apache2.2 */ Class [ class test ] { @@ D:\www\MyProjecttest\index5.php 13-21 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [3] { Property [ private $A ] Property [ public $B ] Property [ protected $C ] } - Methods [1] { Method [ public method test ] { @@ D:\www\MyProjecttest\index5.php 18 - 20 } } } this is a test function
更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《PHP基本語法入門教程》、《PHP運算與運算符用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》PHP教程
希望本文所述對大家PHP程序設(shè)計有所幫助.PHP教程
轉(zhuǎn)載請注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/1302.html