PHP - overloading system function, debugging…
Today I needed to find a file where is called PHP system function, it was to find the place where the email is send. The problem was that the system is huge and messy. There is no wrapper (PHPMailer or something) which will be sending the emails. You will need to install APD, it’s a PECL extension. After that you can overload the mail function and with debug_backtrace get the stacktrace.
// code of the override function
$code=<<<'CODE'
$trace=debug_backtrace();
$caller=array_shift($trace);
echo 'mail() called by '.$caller['function']
if (isset($caller['class']))
echo 'in '.$caller['class'];
CODE;
//install override
override_function('mail', '$to,$subject,$msg,$hdrs,$params', $code);
Did you found this article helpful?
Buy me a coffee :)
Buy me a coffee :)













I would like to thank you for the efforts you’ve put in caligraphy this website. I’m hoping the same elevated-degree website column from you in the upcoming as well. Actually your creative caligraphy skills has encouraged me to get my own blog now. Actually the blogging is spreading its wings go hungry. Your scribble up is a profitable example of it.