(PECL runkit7 >= 未知)
runkit7_method_rename — 動態更改指定方法的名稱
注意:此函式不能用於操作目前正在執行(或鏈式)的方法。
class_name
要重新命名方法的類別
source_method_name
要重新命名的方法的名稱
target_method_name
重新命名的方法的新名稱
範例 #1 runkit7_method_rename() 範例
<?php
class Example {
function foo() {
return "foo!\n";
}
}
// 將 'foo' 方法重新命名為 'bar'
runkit7_method_rename(
'Example',
'foo',
'bar'
);
// 輸出重新命名後的函式
echo (new Example)->bar();
?>
以上範例將輸出
foo!