是否有可能取代PHP中的函数(如邮件),并使其做一些其他的事情? [英] Is it possible to replace a function in php (such as mail) and make it do something else?

查看:104
本文介绍了是否有可能取代PHP中的函数(如邮件),并使其做一些其他的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在PHP中重写一个函数(比方说mail()函数),并且在从现在开始调用mail()的时候想让它变成这样,它会加载我的版本的mail(),而不是默认的PHP版本。这是可能的PHP?



我想这样做的原因是因为我有成千上万的代码行调用mail(),我不想重写所有这些。

另外为了将来的参考,在计算机编程中,当你做这样的事时,它叫什么?

感谢

解决方案

有一个扩展允许您覆盖函数。它意味着用于调试,但我想你可以用它来满足你的需求。看一看:



http://www.php.net/manual/en/function .override-function.php



如果您想在您的版本中调用原始函数,请确保您阅读以下评论:
http://no.php.net/manual/en/function.override-function.php#50821


I want to rewrite a function in PHP (let's say the mail() function), and want to make it so when I call mail() from now on, it will load my version of mail() and not the default php version. Is this possible in php?

The reason I want to do this is because I have thousands of lines of code which call mail() and I don't want to rewrite all of them.

Also for future reference, in computer programming, what is it called when you do something like this?

Thanks

解决方案

There is an extension that allows you to override functions. It is meant to be used for debugging, but I guess you can use it for your needs. Take a look:

http://www.php.net/manual/en/function.override-function.php

If you wish to call the original function within your version, make sure you read this comment: http://no.php.net/manual/en/function.override-function.php#50821

这篇关于是否有可能取代PHP中的函数(如邮件),并使其做一些其他的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆