PHP Function Set_Exception_Handler
Exceptions are a feature in PHP that allows you to handle errors in your code without crashing your whole application. When an exception is thrown, the script stops running and jumps to the first catch block that matches the error type. This enables you to separate your error handling code from the rest of the application and makes it readable.
In most programming languages, there are different ways to handle exceptions. One common method is to surround dangerous code in a try block and a catch block. Whenever an exception occurs, the catch block will be executed and the rest of the program will continue. This is an excellent way to harden your application against bugs. However, it is very difficult to catch every possible exception, so errors sometimes slip through.
To handle uncaught errors, you can use a php function called set_exception_handler. This function sets a user-defined exception handler that is notified of all uncaught PHP errors and can then choose to halt the script (script halts) or pass the error object directly to higher level exception handlers for processing (e.g. print error message, log the error to a log file). Alternatively, you can create your own top level exception handler and implement your own error handling functions. In that case, you can customize the error message and error severity levels that should be matched with the bit masks for error level constants. Creating your own custom exception handler requires creating a custom class that can inherit properties from the core exception class and add your own functions to it.