PHP - 覆盖现有功能 [英] PHP - override existing function
本文介绍了PHP - 覆盖现有功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以重新声明一个现有的函数,名称相同但代码不同吗?或者以某种方式禁用"旧功能?
我想重新定义一个核心的 WordPress 功能,但由于插件和主题经常调用这个功能,我需要保持相同的功能名称.
解决方案
仅当您使用像 APD 这样扩展了 zend 引擎的东西来实现这一点时:
注意:Runkit 似乎是比 APD 更好的选择,因为它更专门用于此目的,并且允许您在不同的地址保持原始方法不变.
Can I redeclare a existing function, with the same name, but different code? Or somehow "disable" the old function?
I want to redefince a core WordPress function, but since plugins and theme call this function a lot, I need to keep the same function name.
解决方案
Only if you use something like APD that extends the zend engine to allow for that:
Note: Runkit seems like a better option than APD since it's more specific to this purpose and would allow you to keep the original method intact at a different address.
这篇关于PHP - 覆盖现有功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文