<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                **#類原生代碼:** ``` namespace php8; class Top{ public function getTop(){ echo 'my name is getTop'; } } trait My{ public function getMy(){ echo 'my name is getMy'; } } /** * @host www.yzmedu.com */ class Person extends Top{ public static $sex='nan'; public $name; public $age; const HOST='www.yzmedu.com'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } use My; } ``` &emsp; **1.獲取類的構造函數** ``` class Person{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } } $rf=new ReflectionClass('Person'); echo "<pre>"; print_r($rf->getConstructor()); echo "</pre>"; ``` &emsp; **2.獲取類名** ``` class Person{} $rf=new ReflectionClass('Person'); echo $rf->getName(); ``` &emsp; **3.獲取類名的短名** ``` namespace php8; class Person{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } } $rf=new \ReflectionClass('php8\Person'); echo $rf->getShortName(); ``` **4.獲取屬性** ``` <?php namespace php8; class Person{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } } $rf=new \ReflectionClass('php8\Person'); $arr=$rf->getProperties(); echo "<pre>"; print_r($arr); echo "</pre>"; ?> ``` **5.獲取方法** ``` namespace php8; class Person{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new \ReflectionClass('php8\Person'); $arr=$rf->getMethods(); echo "<pre>"; print_r($arr); echo "</pre>"; ``` &emsp; **6.獲取命名空間** ``` <?php namespace php8; class Person{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new \ReflectionClass('php8\Person'); echo $rf->getNamespaceName(); ?> ``` &emsp; **7.獲取父類** ``` <?php namespace php8; class Top{} class Person extends Top{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new \ReflectionClass('php8\Person'); echo "<pre>"; print_r($rf->getParentClass()); echo "</pre>"; ?> ``` &emsp; **8.獲取接口** ``` <?php interface A{} interface B{} class C implements A,B{} $rf=new \ReflectionClass('C'); echo "<pre>"; print_r($rf->getInterfaces()); echo "</pre>"; ?> ``` &emsp; **9.獲取靜態屬性** ``` <?php class Person{ public $name; public $age; static public $sex='nan'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); echo "<pre>"; print_r($rf->getStaticProperties()); echo "</pre>"; ?> ``` &emsp; **10.獲取traits** ``` <?php trait mytrait{ public function gettrait(){ echo "my name gettrait"; } } trait trait2{ public $job; } class Person{ public $name; public $age; static public $sex='nan'; const HOST='www.yzmedu.com'; use trait2; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } use mytrait; } $rf=new ReflectionClass('Person'); echo "<pre>"; print_r($rf->getTraits()); echo "</pre>"; ?> ``` &emsp; **11.獲取常量** ``` <?php class Person{ public $name; public $age; static public $sex='nan'; const HOST='www.yzmedu.com'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); echo "<pre>"; print_r($rf->getConstants()); echo "</pre>"; ?> ``` &emsp; **12.獲取文檔注釋** ``` <?php /** * @host www.yzmedu.com */ class Person{ public $name; public $age; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); echo "<pre>"; print_r($rf->getDocComment()); echo "</pre>"; ?> ``` &emsp; **13.檢查常量是否已經定義** ``` <?php class Person{ public $name; public $age; const HOST='www.yzmedu.com'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); var_dump($rf->hasConstant('HOST')) ?> ``` &emsp; **14.檢查方法是否已定義** ``` <?php class Person{ public $name; public $age; const HOST='www.yzmedu.com'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); var_dump($rf->hasMethod('show')) ?> ``` **15.檢查屬性是否已定義** ``` <?php class Person{ public $name; public $age; const HOST='www.yzmedu.com'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); var_dump($rf->hasProperty('name')) ?> ``` &emsp; **16.檢查類是否是抽象類** ``` <?php abstract class Person{ abstract function show(); } $rf=new ReflectionClass('Person'); var_dump($rf->isAbstract()) ?> ``` &emsp; **17.檢查類是否聲明為final** ``` <?php final class Person{ public $name; public $age; const HOST='www.yzmedu.com'; public function __construct($n,$a){ $this->name=$n; $this->age=$a; } public function say(){ echo "my name is {$this->name},my age is {$this->age}"; } public static function show(){ echo "my name is php8"; } } $rf=new ReflectionClass('Person'); var_dump($rf->isFinal()) ?> ``` &emsp; ### **系統的學習PHP** 關注:PHP自學中心,回復相應的關鍵詞,領取以下視頻教程 **全面講解正則表達式【php版】** 公眾號里回復:763641 &emsp; #### **還有其他的教程的關鍵詞,請關注公眾號查看每天分享的文章教程的頭部** ![](https://img.kancloud.cn/96/af/96af322d2cdc53d3fbbe981affa60c7f_150x150.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看