Home  >  Article  >  Backend Development  >  PHP如何替换或重定义内置函数

PHP如何替换或重定义内置函数

WBOY
WBOYOriginal
2016-06-06 20:28:072682browse

如果想用自定义的同名函数,替换PHP内置的函数,这个该如何实现

回复内容:

如果想用自定义的同名函数,替换PHP内置的函数,这个该如何实现

http://php.net/manual/zh/function.override-function.php
我不会PHP

你为什么要覆盖内置函数?难道别人的有bug? 如果是达不到你的需要,你可以重新定义一个函数。
覆盖内置函数按我的理解是很危险的行为,假如你的有问题,其他php模块依赖这个函数岂不是都会出错?

不提倡这么做,建议你使用namespace来解决问题

重写 PHP 内建函数,未实践

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn