Exploring Methods for capturing php error messages

Source: Internet
Author: User
Tags parse error php error

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.

Copy codeThe 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 => D: \ web \ tbc \ error_test.php [line] => 5)
Then you can write logs based on $ msg.

Related Article

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.