How PHP sets the error reporting level for the error_reporting () function

Source: Internet
Author: User
Tags php error
The error_reporting () function kneels and you give the PHP error which should be reported. This function to set the error_reporting instruction at run time.

PHP has many error levels that you can use to set the level at which the script runs. If you do not set an optional parameter, level,error_reporting () returns only the current error reporting level.

Error Reporting Level: Specifies the circumstances under which the error in the script code (where the error is generalized, including e_notice attention, e_warning warning, e_error fatal error, etc.) is output in the form of an error report. To set the error reporting level method:

  1. Modify PHP config file php.ini this way after setting error_reporting, restarting the Web server will take effect forever. Take the XAMPP integration package as an example, open the profile php.ini and see the default values for error report level error_reporting, as follows: Error_reporting=e_all & ~e_deprecated & ~e_ STRICT means to report all errors, but in addition to the e_deprecated and e_strict of the two. Modify it to: Error_reporting=e_all & ~e_notice means to report all errors, except E_notice. This is also the most commonly used error reporting level, and it does not report errors that note classes (such as those that use undefined variables). Save and take effect after restarting the Web server.

  2. This method, which is set using the error_reporting () function , can take effect immediately. But limited to the following area of the error_reporting () function call in the current script. the int error_reporting ([int $level]) parameter can be an integer or a corresponding constant identifier, and it is recommended to use the form of a constant. The return value is the value of the error report level at the current position (integer value).

  3. Some error reporting levels are listed below:

    1. E_error reports a fatal error that causes the script to terminate running

    2. E_warning Report Runtime warning class error (script does not terminate running)

    4. E_parse report compile-time parsing errors

    8. E_notice report notification class error, script may produce error

    32767 E_all Report all possible errors (different PHP versions, constant E_all values may also vary)

    Error_reporting (e_all ^ e_notice); All errors are reported except for E_notice

    Error_reporting (E_error); Only fatal errors are reported

echo error_reporting (E_error | e_warning | E_notice); Only reports E_error, e_warning, and e_notice three kinds of bad job alerts: The default value of Display_errors in the profile php.ini is on, which means that the error prompt is displayed, and if set to OFF, all error prompts are turned off.

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: 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.