: This article describes how to capture the Fatalerror in PHP. if you are interested in the PHP Tutorial, refer to it. This article mainly introduces how to capture the Fatal error in PHP. you can use register_shutdown_function to capture the Fatal error. For more information, see
Fatal errors do not need to be captured, but in a complicated program, it is difficult to handle fatal errors due to memory insufficiency.
For example, when fatal error is fetch in the MySQL class, it is difficult to locate the real problem.
In PHP exception handling, you can use set_error_handler to capture. However, you can only capture NOTICE/WARNING-level errors. E_ERROR is powerless.
Register_shutdown_function can solve the problem of set_error_handler.
You can use this function to register the callback function for program termination to capture common errors that cannot be captured. then, you can use error_get_last to determine the errors. This makes it easy to locate difficult problems.
The code is as follows:
Function shutdown_function ()
{
$ E = error_get_last ();
Print_r ($ e );
}
Register_shutdown_function ('shutdown _ function ');
The above describes how to capture the Fatal error in PHP, including some content. I hope my friends who are interested in the PHP Tutorial can help me.