PHP Conference Japan 2024

runkit7_function_redefine

(PECL runkit7 >= 未知)

runkit7_function_redefine 使用新的實作取代函式定義

描述

runkit7_function_redefine(
    字串 $function_name,
    字串 $argument_list,
    字串 $code,
    布林值 $return_by_reference = null,
    字串 $doc_comment = null,
    字串 $return_type = ?,
    布林值 $is_strict = ?
): 布林值
runkit7_function_redefine(
    字串 $function_name,
    閉包 $closure,
    字串 $doc_comment = null,
    字串 $return_type = ?,
    布林值 $is_strict = ?
): 布林值

注意預設情況下,只有使用者空間的函式可以被移除、重新命名或修改。若要覆寫內建函式,您必須在 php.ini 中啟用 runkit.internal_override 設定。

參數

function_name

要重新定義的函式名稱

argument_list

函式將接受的新參數列表

code

新的程式碼實作

closure

定義函式的 閉包

return_by_reference

函式是否應該透過引用返回。

doc_comment

函式的文件註釋。

return_type

函式的返回類型。

is_strict

函式是否如同在 strict_types=1 的檔案中宣告一樣運作

返回值

成功時返回 true,失敗時返回 false

範例

範例 #1 runkit7_function_redefine() 範例

<?php
function testme() {
echo
"原始 Testme 實作\n";
}
testme();
runkit7_function_redefine('testme','','echo "新的 Testme 實作\n";');
testme();
?>

上述範例將輸出

Original Testme Implementation
New Testme Implementation

參見

新增筆記

使用者貢獻的筆記

此頁面沒有使用者貢獻的筆記。
To Top