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