Error_reporting () Set the error level of PHP

Source: Internet
Author: User
Error_reporting (e_all ^ e_notice ^ e_strict ^ e_deprecated);
Guys, help me explain what this line of code is aware of, set what error level,

Reply content:

Error_reporting (e_all ^ e_notice ^ e_strict ^ e_deprecated);
Guys, help me explain what this line of code is aware of, set what error level,

Check out the official PHP documentation to know: error_reporting
The above code means that all errors except E_notice e_scrict e_deprecated are reported.
E_all ^ E_notice ^ e_strict ^ e_deprecated This is a continuous XOR operation.
E_all E_notice e_strict e_deprecated These are constants, the corresponding binary is roughly the following

E_NOTICE 00001 E_STRICT 00010E_DEPRECATED 00100E_ALL 11111

After doing the XOR or operation, the equivalent is to change the same into 0 different into 1 that is to say the result is that the e_all excluded the different or operation of the few.
The above constants correspond to the value of purely fictitious, can try to print out to see exactly how much.
Similarly, you can use E_notice | E_strict such a way to set multiple levels for reporting. The principle is that after the operation or manipulation there are 1 1, all 0 0

What is represented here is that it outputs all types of errors (E_all), but excludes E_notice, e_strict, e_deprecated, and other types of errors.

Here is a bit arithmetic technique, because E_all is a full 1 number, and E_notice, E_strict, and e_deprecated are all 1 numbers, these different or a few, forming a log level to exclude these several.

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