<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                **一.注釋定義** ``` /** * @api http://www.yzmedu.com/api */ function show($name){} ``` &emsp; **二.獲取注釋** ``` $ref=new ReflectionFunction("show"); $doc=$ref->getDocComment(); $api=substr($doc, strpos($doc, "@api") + strlen("@api "),-2); ``` &emsp; **三.Attributes語法** ``` #[Name] #[Name1,Name2] #[Name(Arguments)] #[Name(Argunment1,Arguments2,ArgumentN)] #[Name1(Argument),Name2(Argument),Name3(Argument)] ``` &emsp; **四.注解定義** 1.單參數 ``` #[api("http://www.yzmedu.com/api")] function show($name){} ``` 2.多參數 ``` #[myattr("api","http://www.yzmedu.com/api")] #[api("http://www.yzmedu.com/api")] ``` &emsp; **五.獲取注解** ``` $ref=new ReflectionFunction("show"); $attr=$ref->getAttributes("api")[0]; $name=$attr->getName(); $value=$attr->getArguments(); ``` &emsp; **六.ReflectionAttribute類結構** ``` final class ReflectionAttribute { /** * @return string The name of the attribute, with class names resolved. */ public function getName(): string {} /** * @return array Arguments passed to the attribute when it is declared. */ public function getArguments(): array {} /** * @return object An instantiated class object of the name, with arguments passed to the constructor. */ public function newInstance(): object {} } ``` &emsp; **七.函數注解類使用** ``` #[Attribute(Attribute::TARGET_FUNCTION)] class MyAttr{ public function __construct($name, $value) { echo "$name,$value"; } } #[MyAttr("api","http://www.yzmedu.com/api")] function show(){} $ref=new ReflectionFunction("show"); $attr=$ref->getAttributes("MyAttr")[0]->newInstance(); ``` &emsp; **八.注解類類型** ``` TARGET_CLASS //類的注解類 TARGET_FUNCTION //函數注解類 TARGET_METHOD //方法注解類 TARGET_PROPERTY //屬性注解類 TARGET_CLASS_CONSTANT //類常量注解類 TARGET_PARAMETER //參數注解類 TARGET_ALL ``` &emsp; **九.函數注解類高級配置** ``` #[Attribute(Attribute::TARGET_FUNCTION)] class Myattr{ public $name; public $value; public $number; public function __construct($name,$value,$number){ $this->name=$name; $this->value=$value; $this->number=$number; } public function say(){ echo "{$this->name}--{$this->value}--{$this->number}"; } } #[Myattr('api','http://www.yzmedu.com/api','10')] function show(){} $ref=new ReflectionFunction("show"); $attr=$ref->getAttributes('Myattr')[0]; $obj=$attr->newInstance(); $obj->say(); ``` &emsp; **十.類注解類使用** ``` #[Attribute(Attribute::TARGET_CLASS)] class MyAttr{ public function __construct($name, $value) { echo "$name,$value"; } } #[MyAttr("api","http://www.yzmedu.com/api")] class Person{} $ref=new ReflectionClass("Person"); $ref->getAttributes("MyAttr")[0]->newInstance(); ``` &emsp; **十一.類注解高級配置** ``` #[Attribute(Attribute::TARGET_CLASS)] class Myattr{ public $name; public $value; public $number; public function __construct($name,$value,$number){ $this->name=$name; $this->value=$value; $this->number=$number; } public function say(){ echo "{$this->name}--{$this->value}--{$this->number}"; } } #[Myattr('api','http://www.yzmedu.com/api','10')] class Person{} $ref=new ReflectionClass("Person"); $attr=$ref->getAttributes('Myattr')[0]; $obj=$attr->newInstance(); $obj->say(); ``` &emsp; ### **系統的學習PHP** 關注:PHP自學中心,回復相應的關鍵詞,領取以下視頻教程 **Redis6.0全套實戰教程【面試題講解】** 公眾號里回復:884613 &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>

                              哎呀哎呀视频在线观看