Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14625 reviews 1734 hosting providers

Questions & Answers

how to set PHP default exception handler

Apr 2, 2012 by chris

How can I set the default PHP exception handler?


1 Answer

0 votes
Apr 2, 2012 by lionhost
hey Chris

you can use the following code

 set_exception_handler (  $exception_handler )

This function must be defined before calling set_exception_handler(). This handler function needs to accept one parameter, which will be the exception object that was thrown.

set_exception_handler() example
function exception_handler($exception) {
  echo "Uncaught exception: " , $exception->getMessage(), "\n";


throw new Exception('Uncaught Exception');
echo "Not Executed\n";