gpt4 book ai didi

php - 如何 "inject"内置php函数

转载 作者:行者123 更新时间:2023-12-03 22:54:51 25 4
gpt4 key购买 nike

如何修改内置 php 函数的返回值而不用另一个名称创建新函数并将所有使用的函数重命名为新函数?例如

function time() {
return time()-1000;
}

当然这不会通过,不是有类似“function time() extends time() {}”之类的东西吗?

最佳答案

随着APD PECL扩展你可以renameoverride内置函数。

//we want to call the original, so we rename it
rename_function('time', '_time()');

//now replace the built-in time with our override
override_function('time', '', 'return my_time();');

//and here's the override
function my_time($){
return _time()-1000;
}

APD 旨在用于调试目的,因此这不是您真正应该考虑用于生产代码的技术。

关于php - 如何 "inject"内置php函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6640579/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com