I usually use my code using a variable to register events, then decide what to do at the exit point by registering the shutdown function:
class flightRecoder { var $data; var $err; function __constructor() { $this->data=array(); } function error($errno, $errstr, $errfile, $errline) { if ($this->err<$errno) { $this->err=$errno; } $this->note("ERROR! $errno $errstr", $errfile, $errline); } function note($note, $infile, $atline) { $this->data[]="$note in $infile at $atline"; } function finish() { if ($this->errno || rand(1,20)==19) { .... } } } $log=new flightRecorder(); register_shutdown_function(array($log, 'finish')); set_error_handler(array($log, 'error'));
In your case, you just need to ensure that error_logging has been enabled (to catch fatal errors), and then insert a note in front of any exit statement.
source share