PHP Error-Level setting method _php Tips

Source: Internet
Author: User
Tags php error
When PHP is running, it gives different hints for errors of varying severity.

Eg: when $a is not declared, it is added directly, the value is null, and when added, it is counted as 0来. However, it prompts notice, that is, attention.

We are in the development, in order to the standardization of the procedure, the error level, the higher notice level of the report, help us to quickly locate errors and code specifications, but, in the product online, website OperationIn the 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 out. Increase the risk of being attacked
Therefore, after the website is on-line, should let the error level reduce, the small error even does not report.

To Modify the error level:

Modify error_reporting option in 1:php.ini
2: Can be in the PHP page, with the error_reporting () function to modify

The error level is represented by a value of 2:1111 1111 1111 111 from left to right, 1 per digit, representing an error level

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


eg

     It's all in the papers.: error_reporting (11);
     don't report notice .: error_reporting (3);
     No mistakes are 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, others are reported: Error_reporting (E_all & ~e_notice);

In the development, the error level is higher, in the on-line product, the error level should be low: +

Copy Code code 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);
}

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.