Home >Backend Development >PHP Tutorial >How to catch Fatal error in PHP_PHP tutorial
Fatal errors generally do not need to be caught, but in a complex program, if a fatal error occurs due to insufficient memory, it will be difficult to handle.
For example, the fatal error occurs when fetching in the MySQL class. At this time, it is difficult to locate the real problem.
PHP exception handling can be captured through set_error_handler. However, it can only capture NOTICE/WARNING level errors, and there is nothing you can do about E_ERROR.
register_shutdown_function can solve the shortcomings of set_error_handler.
By registering the program end callback function with this function, you can catch errors that cannot be caught normally. Then use error_get_last to judge the errors. It will be easier to find problems that are difficult to locate.