During PHP Development, error_reporting (report_level) is often used to debug your program. The possible values of report_level are listed below.
During PHP Development, error_reporting (report_level) is often used to debug your program. The possible values of report_level are listed below.
Value |
Constant |
Description |
1 |
E_ERROR |
This is a serious error and cannot be recovered, such as a location exception or insufficient memory. |
2 |
E_WARNING |
Warning: The most common error, such as a function Parameter error. |
4 |
E_PARSE |
Parsing error, generated when parsing the PHP file, and forced PHP to exit before execution |
8 |
E_NOTICE |
An announcement indicates that some unknown variables may be operated. You can enable the notice during development to ensure that the program is "security notice". in the official system, the notice should be closed. |
16 |
E_CORE_ERROR |
This internal error is caused by PHP loading expansion failure, and may cause PHP to stop running and exit. |
32 |
E_CORE_WARNING |
Warning during PHP initialization (non-fatal error) |
64 |
E_COMPILE_ERROR |
A compilation error occurs during compilation, which causes PHP to exit. |
128 |
E_COMPILE_WARNING |
The compile warning is used to tell the user some unrecommended syntax information. |
256 |
E_USER_ERROR |
A user-defined error will lead PHP to exit. it is from PHP itself, but from the script file. |
512 |
E_USER_WARNING |
The script uses it to notify a failed execution, and PHP also uses E_WARNING to notify |
1024 |
E_USER_NOTICE |
User-defined announcements are used to indicate possible errors in the script |
2048 |
E_STRICT |
Code Standardization warning (how to modify to forward compatibility) |
4096 |
E_RECOVERABLE_ERROR |
Near fatal runtime error. if not captured, it is considered as E_ERROR. |
8191 |
E_ALL |
All errors except E_STRICT (8191 in PHP6, that is, all errors are included) |
Example:
Any number of the above options can be connected with "OR" (OR |), so that all required levels of errors can be reported. For example, the following code disables user-defined errors and warnings, performs some operations, and then restores to the original error level:
PHP code
-
- // Disable error reporting
- Error_reporting (0 );
- // Report running errors
- Error_reporting (E_ERROR | E_WARNING | E_PARSE );
- // Report all errors
- Error_reporting (E_ALL );
- Error_reporting (7 );
- Set php error detection level
- E_ERROR-fatal runtime error (1)
- E_WARNING-runtime warning (non-fatal error) (2)
- E_PARSE-parsing error during compilation (4)
- 1 + 2 + 4 = 7
- ?>