PHP8 runkit7_method_remove — 動(dòng)態(tài)刪除給定的方法

2023-10-07 10:52 更新

(PECL runkit7 >= Unknown)

runkit7_method_remove — 動(dòng)態(tài)刪除給定的方法

說(shuō)明

runkit7_method_remove(string $class_name, string $method_name): bool
注意: 此函數(shù)不能用來(lái)操作當(dāng)前正常運(yùn)行(或運(yùn)行鏈上)的方法。

參數(shù)

class_name

要?jiǎng)h除方法的類(lèi)。

method_name

要?jiǎng)h除的方法的名稱(chēng)。

返回值

成功時(shí)返回 true, 或者在失敗時(shí)返回 false。/

示例

示例 #1 runkit7_method_remove() example

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

function bar() {
return "bar!\n";
}
}

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

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

?>

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

bar

參見(jiàn)

  • runkit7_method_add() - 動(dòng)態(tài)地向給定類(lèi)添加新方法。
  • runkit7_method_copy() - 從一個(gè)類(lèi)復(fù)制方法到另一個(gè)類(lèi)。
  • runkit7_method_redefine() - 動(dòng)態(tài)地更改給定方法的代碼。
  • runkit7_method_rename() - 動(dòng)態(tài)地更改給定方法的名稱(chēng)。
  • runkit7_function_remove() - 移除函數(shù)定義。


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)