Fatal error generally does not need to be captured, but in a complex program, Fatal error can be difficult to handle if an occasional memory shortage occurs.
Like what. Fatal error when you fetch in the MySQL class. It's hard to pinpoint the real problem at this point.
PHP exception handling can be captured by Set_error_handler. But can only catch notice/warning level of error, for E_error is powerless.
Register_shutdown_function can solve the Set_error_handler deficiency.
By registering a good program with this function to end the callback function, you can catch errors that are not normally caught. Then the error is judged by Error_get_last. It is easy to find a problem that is difficult to locate.
Copy the Code code as follows:
function Shutdown_function ()
{
$e = Error_get_last ();
Print_r ($e);
}
Register_shutdown_function (' shutdown_function ');
http://www.bkjia.com/PHPjc/781814.html www.bkjia.com true http://www.bkjia.com/PHPjc/781814.html techarticle Fatal error generally does not need to be captured, but in a complex program, Fatal error can be difficult to handle if there is a chance of running out of memory. For example, the. Fatal error is in the MySQL class ...