<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國際加速解決方案。 廣告
                [TOC] ## 概述 繼承了 ReflectionFunctionAbstract ## 語法 ``` ReflectionFunction::__construct — Constructs a ReflectionFunction object ReflectionFunction::export — Exports function ReflectionFunction::getClosure — Returns a dynamically created closure for the function ReflectionFunction::invoke — Invokes function ReflectionFunction::invokeArgs — Invokes function args ReflectionFunction::isDisabled — Checks if function is disabled ReflectionFunction::__toString — To string ``` ## 示例 ### Hello World ``` function A($a1='',$a2=''){ return $a1.$a2; } $r = new ReflectionFunction("A"); var_dump($r->getName()); // A var_dump($r->getNumberOfParameters()); // 2 var_dump($r->invokeArgs(["hello","world"])); // helloworld var_dump($r->invoke("hello","world")); // helloworld ``` ### 判斷函數,可選與否 ``` $argsArr = [ 'name' => 'Anderson Lucas Silva de Oliveira', 'age' => 21, 'hobbie' => 'Play games' ]; function processUserData($name, $age, $job = "", $hobbie = "") { $msg = "Hello $name. You have $age years old"; if (!empty($job)) { $msg .= ". Your job is $job"; } if (!empty($hobbie)) { $msg .= ". Your hobbie is $hobbie"; } echo $msg . "."; } $refFunction = new ReflectionFunction('processUserData'); $parameters = $refFunction->getParameters(); $validParameters = []; foreach ($parameters as $parameter) { // 缺少不可選函數 if (!array_key_exists($parameter->getName(), $argsArr) && !$parameter->isOptional()) { throw new DomainException('Cannot resolve the parameter' . $parameter->getName()); } // 缺少可選函數,跳過 if(!array_key_exists($parameter->getName(), $argsArr)) { continue; } $validParameters[$parameter->getName()] = $argsArr[$parameter->getName()]; } $refFunction->invoke(...$validParameters) ```
                  <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>

                              哎呀哎呀视频在线观看