Exploring methods for capturing php error information _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.