Explore a detailed method for capturing php error messages
- 2020-06-12 08:36:18
- OfStack
PS:
1. Catch PHP syntax errors
2. Serious mistakes
These two types of errors cannot be caught with normal set_error_handle, which is a technique for catching such errors
//test.php page
error_reporting(0);
register_shutdown_function('PageOnShutdown');
include('error_test.php');
function PageOnShutdown()
{
$msg = error_get_last();
print_r($msg);
}
//error_test.php page
$a = 1 + 2
$b
Then output test.php prints out
Array ( [type] = > 4 [message] = > parse error [file] = > D:\web\tbc\error_test.php [line] = > 5 )
Then write to the log based on getting $msg