Php error-level settings _ PHP Tutorial

Source: Internet
Author: User
Php error-level setting method. During PHP running, different prompts are given for errors with different severity levels. Eg: when $ a is not declared, it is directly added. The value is NULL. when it is added, it is regarded as 0. However, it prompts NOTICE, that is, note During PHP running, different prompts are given for errors with different severity levels.

Eg: when $ a is not declared, it is directly added. The value is NULL. when it is added, it is regarded as 0. However, it prompts NOTICE, that is, attention.

During development, for the sake of program standardization, we also report errors with higher levels of NOTICE, which helps us to quickly locate errors and code standards. However, after the product is launched, it is not appropriate to report so many errors during Website operation.

1: The customer is not impressed by this error.
2: when an error is reported, the absolute path of the website, such as D: \ www \ 1015, is reported. this increases the risk of being attacked.
Therefore, after the website is launched, the error severity should be reduced, with fewer or even no errors reported.

Modify the error severity:

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

The error level is represented by a binary value: 1111 1111 1111 111 from left to right. the value 1 indicates an error level.

Fatal error: 0000 0000 0000 001 enabled 1
Warning error: 0000 0000 0000 010 enabled 2
NOTICE warning: 0000 0000 0001 enabled 8


Eg:

     All reported: Error_reporting (11 );
     Do not report NOTICE: Error_reporting (3 );
     No errors are reported.: Error_reporting (0 );

The system replaces the values of various levels with system constants.

E_ERROR 1
E_WARNING 2
E_NOTICE 8

All errors are reported: error_reporting (E_ALL );

Except for NOTICE, the error error_reporting (E_ALL &~ E_NOTICE );

During development, the error reporting level is higher. in online products, the error reporting level is lower: +

The code is as follows:


Define ('debug', true); // declare a DEBUG mode during development
If (defined ('debug') {// it is detected that it is in development mode.
Error_reporting (E_ALL );
} Else {
Error_reporting (0 );
}

Warning. different prompts are given for errors with different severity levels. Eg: when $ a is not declared, it is directly added. The value is NULL. when it is added, it is regarded as 0. However, it prompts NOTICE, that is, note...

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.