1

I want to catch all the errors in my code. I know that we can use the set_error_handler function to set a exception handler function for doing it, like this. But, if I use this method previous handler will be disabled, and I do not want something like that. Do you have any idea?

beforehand appreciate any help

Community
  • 1
  • 1
Pedram
  • 828
  • 9
  • 24
  • 1
    Does this help: _It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE._ [From the manual](http://php.net/manual/en/function.set-error-handler.php) – RiggsFolly Jan 07 '17 at 15:07
  • thanks for your answer. I looking for a way to catch the exceptions after or before executing previously defined exception handler. Can I write: `function exception_error_handler($errno, $errstr, $errfile, $errline ) { //do something restore_error_handler(); try{throw new ErrorException($errstr, $errno, 0, $errfile, $errline);} catch(Exception $e){} finally{set_error_handler("exception_error_handler");} } set_error_handler("exception_error_handler");` ? – Pedram Jan 09 '17 at 09:52
  • and, according to the manual: **If the function returns FALSE then the normal error handler continues.** So can I write this for that? : `function exception_error_handler($errno, $errstr, $errfile, $errline ) { try{//do something}catch(Exception $ex){}finally{return false;} } set_error_handler("exception_error_handler");` – Pedram Jan 09 '17 at 10:06
  • I would give it a try and see what happens – RiggsFolly Jan 09 '17 at 10:12

0 Answers0