classkit_method_remove

(PECL)

classkit_method_remove -- Dynamically removes the given method

說明

bool classkit_method_remove ( string classname, string methodname )

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

警示

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

參數

classname

The class in which to remove the method

methodname

The name of the method to remove

返回值

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

範例

例子 1. classkit_method_remove() example

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

// Remove the 'foo' method
classkit_method_remove(
    
'Example',
    
'foo'
);

echo 
implode(' 'get_class_methods('Example'));

?>

上例將輸出:

bar