PHP error levels

Source: Internet
Author: User
Tags php error reporting

In many cases, PHP files may encounter some very difficult-to-troubleshoot errors, such as output of large white pages. It is possible that the PHP error level shields some non-fatal errors, resulting in no error prompt. Therefore, understanding and familiarity with PHP error levels may become a new method for debugging errors.
Php. by default, the PHP Error Reporting level is E_NOTICE, and E_ALL indicates reporting all non-fatal errors, because these errors may cause major problems (such as using undefined variables ).

All errors are displayed, except reminders and coding standard warnings.

The error report is a bit field. You can add up the numbers to get the expected error report level.

E_ALL-all errors and warnings (excluding E_STRICT)

E_ERROR-fatal runtime error

E_WARNING-runtime warning (non-fatal error)

E_PARSE-parsing error during compilation

E_NOTICE-runtime reminder (these are often caused by bugs in your code, and may also be caused by intentional behavior .)

E_STRICT-code standardization warning, allowing PHP to recommend how to modify code to ensure optimal interoperability forward compatibility.

E_CORE_ERROR-fatal error during PHP Initialization

E_CORE_WARNING-warning during PHP initialization (non-fatal error)

E_COMPILE_ERROR-fatal error during compilation

E_COMPILE_WARNING-warning during compilation (non-fatal error)

E_USER_ERROR-custom error message

E_USER_WARNING-custom warning message

E_USER_NOTICE-custom reminder message

If it is set to: E_ALL | E_STRICT, it indicates to record all the error information, which may lead to a lot of error code on the website. But it should be said to be a good thing for programmers, you can optimize the code to the optimum. Some non-fatal errors do not affect the running of the program, but increase the burden on PHP, usually increasing the website process (such as the application pool of IIS).
Adjust error reports in PHP
Once you set PHP to display the errors that have occurred, you may want to adjust the error report level. You can set the PHP installation as a whole or as an independent script to report or ignore different error levels. Table 7-1 lists most levels, but they are generally one of the following three levels:
L note (notice), which does not prevent script execution and may not be a problem;
L warning, which indicates a problem, but does not prevent script execution;
L error, which prevents the script from continuing to run (including common parsing errors, which fundamentally prevents the script from running ).
Table 7-1 PHP Error Report Settings, used together with the error_reporting () function, or in the php. ini file. Note that the value of E_ALL is different from that of the old PHP version and does not include E_STRICT (but exists in PHP 6)

No. Regular Report
1 E_ERROR Fatal runtime error (it will prevent script execution)
2 E_WARNING Runtime warning (non-fatal error)
(Continued)
No. Regular Report
4 E_PARSE Parsing error
8 E_NOTICE Note (things may or may not be a problem)
256 E_USER_ERROR The error message generated by the trigger_error () function.
512 E_USER_WARNING User-generated warning, generated by trigger_error () function
1024 E_USER_NOTICE Attention generated by the user, generated by the trigger_error () function
2048 E_STRICT Suggestions on compatibility and interoperability
8191 E_ALL All errors, warnings, and suggestions
 

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.