Is it possible to replace a function in php (such as mail) and make it do something else?

前端 未结 4 992
失恋的感觉
失恋的感觉 2020-11-28 11:45

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 de

4条回答
  •  日久生厌
    2020-11-28 12:42

    You can use regexps to replace the function name in your files. What app you use is up to you, but I'd recommend the ovely-pricey Powergrep (unless you won't need it again).

    replace

       (\s+)mail([\s(]+)
    

    to

       $1new_function_name$2
    

    and

       ^mail([\s(]+)
    

    to

       new_function_name$1
    

    Sorry for my regexp-fu, I don't know how to search for either spaces OR begining of line in one expression.

提交回复
热议问题