Describes how to capture php error messages. PS: 1. catch PHP syntax errors 2. severe errors the following two types of errors cannot be captured with the normal set_error_handle. this is the technique for capturing such errors and copying the code: test. php page
PS:
1. catch PHP syntax errors
2. Serious errors
Normal set_error_handle cannot capture these two types of errors. this is a technique for capturing these errors.
The code is as follows:
// 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
Output test. php to print out
Array ([type] => 4 [message] => parse error [file] => D: \ web \ tbc \ error_test.php [line] => 5)
Then you can write logs based on $ msg.
Listing 1. capturing PHP syntax errors 2. using the normal set_error_handle to catch these two types of errors, this is a trick to capture these errors. the code is as follows: // test. php page...