欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php面向?qū)ο笾瓷涔δ芘c用法分析

 更新時間:2017年03月29日 10:10:34   作者:PHP__廊外詩鴿  
這篇文章主要介紹了php面向?qū)ο笾瓷涔δ芘c用法,結(jié)合實例形式簡單分析了php5面向?qū)ο蠓瓷涞母拍罴熬唧w用法,需要的朋友可以參考下

本文實例講述了php面向?qū)ο笾瓷涔δ芘c用法。分享給大家供大家參考,具體如下:

個人對反射定義的理解:

首先得說說什么叫反射。對于一個新手來說,反射這個概念常常給人一種似懂非懂的 感覺,不知道該如何下手操作。

反射是指:指在PHP運行狀態(tài)中,擴展分析PHP程序,導(dǎo)出或提取出關(guān)于類、方法、屬性、參數(shù)等的詳細信息,同時也包括注釋。這種動態(tài)獲取的信息以及動態(tài)調(diào)用對象的方法 的功能稱為反射API。反射是操縱面向?qū)ο蠓缎椭性P偷腁PI,其功能十分強大,可幫助我們構(gòu)建復(fù)雜,可擴展的應(yīng)用。(注意:php中這種反向操作,實在PHP5之后才完全具備

下面在此我用實例進行說明:

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é)果:

/** * 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程序設(shè)計有所幫助。

相關(guān)文章

最新評論