<kbd id="rj8rh"><s id="rj8rh"></s></kbd>
  • <big id="rj8rh"><s id="rj8rh"></s></big>
  • <small id="rj8rh"><noframes id="rj8rh"><small id="rj8rh"></small>
  • <small id="rj8rh"><sub id="rj8rh"><var id="rj8rh"></var></sub></small><rt id="rj8rh"></rt>
    <nobr id="rj8rh"><menu id="rj8rh"></menu></nobr>

    ReflectionMethod::invoke

    (PHP 5, PHP 7, PHP 8)

    ReflectionMethod::invokeInvoke

    說明

    public ReflectionMethod::invoke(object $object, mixed $parameter = ?, mixed $... = ?): mixed

    執(zhí)行一個(gè)反射的方法。

    參數(shù)

    object

    如果執(zhí)行的方法是靜態(tài)類,那么這個(gè)參數(shù)傳送 null

    parameter

    0,或者傳送給方法的參數(shù)列表??梢酝ㄟ^這個(gè)參數(shù),給方法傳送大量的參數(shù)。

    返回值

    返回方法的返回值

    錯(cuò)誤/異常

    如果 object 并沒有包含一個(gè)可以使用的類實(shí)例,那么將產(chǎn)生 一個(gè) ReflectionException

    如果方法調(diào)用失敗,也會(huì)產(chǎn)生一個(gè) ReflectionException。

    范例

    示例 #1 ReflectionMethod::invoke() example

    <?php
    class HelloWorld {

        public function 
    sayHelloTo($name) {
            return 
    'Hello ' $name;
        }

    }

    $reflectionMethod = new ReflectionMethod('HelloWorld''sayHelloTo');
    echo 
    $reflectionMethod->invoke(new HelloWorld(), 'Mike');
    ?>

    以上例程會(huì)輸出:

    Hello Mike
    

    注釋

    注意:

    如果函數(shù)有參數(shù)需為引用,那么它們必須以引用方式傳入。

    參見