classkit_method_rename

(PECL)

classkit_method_rename -- Dynamically changes the name of the given method

說明

bool classkit_method_rename ( string classname, string methodname, string newname )

注: 本函數不能用於動作現用的正在運行(或運行鏈上)的方法。

警示

本函數是實驗性的。本函數的行為,內含函數名稱以及其它任何關於本函數的文件可能會在沒有知會的情況下隨 PHP 以後的發佈而改變。使用本函數風險自擔。

參數

classname

The class in which to rename the method

methodname

The name of the method to rename

newname

The new name to give to the renamed method

返回值

若果成功則返回 TRUE,失敗則返回 FALSE

範例

例子 1. classkit_method_rename() example

<?php
class Example {
    function 
foo() {
        return 
"foo!\n";
    }
}

// Rename the 'foo' method to 'bar'
classkit_method_rename(
    
'Example',
    
'foo',
    
'bar'
);

// output renamed function
echo Example::bar();
?>

上例將輸出:

foo!