PHP Conference Japan 2024

ReflectionMethod::getPrototype

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

ReflectionMethod::getPrototype取得方法原型 (如果有的話)

說明

public ReflectionMethod::getPrototype(): ReflectionMethod

返回方法的原型。

參數

此函式沒有參數。

回傳值

方法原型的 ReflectionMethod 實例。

錯誤/例外

如果方法沒有原型,則會擲出 ReflectionException 例外。

範例

範例 #1 ReflectionMethod::getPrototype() 範例

<?php
class Hello {

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

}
class
HelloWorld extends Hello {

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

}

$reflectionMethod = new ReflectionMethod('HelloWorld', 'sayHelloTo');
var_dump($reflectionMethod->getPrototype());
?>

以上範例會輸出:

object(ReflectionMethod)#2 (2) {
  ["name"]=>
  string(10) "sayHelloTo"
  ["class"]=>
  string(5) "Hello"
}

另請參閱:

新增註解

使用者貢獻的註解

此頁面沒有使用者貢獻的註解。
To Top