(PECL runkit7 >= 未知)
runkit7_function_redefine — 用新的实现替换函数定义
$function_name,$argument_list,$code,$return_by_reference = null,$doc_comment = null,$return_type = ?,$is_strict = ?$function_name,$closure,$doc_comment = null,$return_type = ?,$is_strict = ?注意: 默认情况下,只能删除、重命名或修改用户空间函数。为了覆盖内部函数,必须在 php.ini 中启用
runkit.internal_override设置。
function_name要重新定义的函数名称
argument_list函数要接受的新参数列表
code新的代码实现
closure一个 closure,用于定义函数。
return_by_reference函数是否应该通过引用返回。
doc_comment函数的文档注释。
return_type函数的返回类型。
is_strict函数的行为是否如同在具有 strict_types=1 的文件中声明一样
示例 #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