How to set PHP error level _php tutorial

Source: Internet
Author: User
PHP at runtime, for different severity of errors, will give different hints.

Eg: when $ A is not declared, it is added directly, the value is null, and the sum is counted as zero. However, it prompts notice, that is, attention.

We in the development, in order to process the normative, the error level, the higher the notice level of the report, help us to quickly locate errors and code specifications, but, after the product on-line, the website operation process, it is not appropriate to report so many mistakes.

1: This error gives the customer a bad impression
2: In the error, the site's absolute path, such as D:\www\1015 are reported. Increase the risk of attack
Therefore, after the site on-line, you should let the error level down, less error or even do not report.

To Modify the error level:

Modify the error_reporting option in 1:php.ini
2: You can use the error_reporting () function to modify the PHP page.

The 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 on 1
Warning warning error: 0000 0000 0000 010 Open 2
NOTICE warning: 0000 0000 0001 000 Open 8


eg

     it's all reported.: error_reporting (11);
     Don't quote notice .: error_reporting (3);
     any mistakes are not reported: error_reporting (0);

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

E_error 1
E_warning 2
E_notice 8

Report All errors: error_reporting (E_all);

In addition to NOTICE, the others are reported: Error_reporting (E_all & ~e_notice);

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

Copy CodeThe code is as follows:
Define (' DEBUG ', true); At development time, declare a debug mode
if (defined (' DEBUG ')) {//detected in development mode
Error_reporting (E_all);
} else {
error_reporting (0);
}

http://www.bkjia.com/PHPjc/327610.html www.bkjia.com true http://www.bkjia.com/PHPjc/327610.html techarticle php at runtime, for different severity of errors, will give different hints. Eg: when $ A is not declared, it is added directly, the value is null, and the sum is counted as zero. However, it prompts notice, that is, pay attention to ...

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