PHP Error Level setting method

Source: Internet
Author: User
In the course of PHP programming, you will encounter more or less error reminders, it is these error hints, guide us to write cleaner code, today first write our main list of error types, first dig pits, write about PHP errors and anomalies related knowledge, slowly pits.

    • Deprecated lowest level error, program continues execution

    • Notice notification level errors such as using undeclared variables directly, the program continues execution

    • Warning Warning Level error, may not get the desired result

    • Fatal error fatal level error fatal level errors, program does not execute down

    • Parse error syntax parsing errors, highest level errors, and even other error messages are not rendered

    • E_user_ related error user settings related errors

Use the Trigger_error () function to set a user-level error/warning/notice information

How do I set the error level?

to modify the error level:

1:php.ini Modify the error_reporting option
2: You can use the error_reporting () function in the PHP page to modify the
The br> error level is represented by a 2 binary value: 1111 1111 1111 111 from left to right, 1 on each bit, representing an error level

fatal error fatal: 0000 0000 0000 001 Open 1
Warning Warning error: 0000 0000 0000 010 on 2
NOTICE warning: 0000 0000 0001 000 Open 8

Eg:

all reported : ER Ror_reporting (11);
do not report notice : error_reporting (3);
Any error is not reported to : error_reporting (0);

The system replaces the values for each level with system constants.

e_error 1
e_warning 2
E_notice 8

Report All errors: error_reporting (E_all);

except NOTICE, others are reported: Error_reporting (E_all & ~e_notice);

in development, the error level is higher, on-line products, the error level is low: +

 define (' DEBUG ', true);//At development time, declare a DEBUG mode if (Defined (' Debug ')} {//Detect in Development mode     Error_reporting (E_all);     } else {error_reporting (0); }

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.