This article mainly introduces the error-level variable Comparison table of PHP error_reporting. you can use the error_reporting () function to set errors in PHP:
Its parameters include string and number representation methods, which have a total of 14 levels. However, I can see other numbers, at first, I thought it meant a certain error interval. later, I finally found the rule:
The code is as follows:
Error_reporting (7) = error_reporting (1 + 2 + 4) = error_reporting (E_ERROR | E_WARING | E_PARSE)
Now, I will summarize it as follows:
Number |
Constant |
Description |
1 |
E_ERROR |
A fatal error occurs when the execution of the script is interrupted, that is, something unrecognizable in the script appears. Example: Error: Invalid parameters. Invalid parameter name |
2 |
E_WARNING |
Some code errors, but do not affect the overall operation Example: Warning: require_once (E:/include/config_base.php) |
4 |
E_PARSE |
Incorrect write specification for characters, variables, or ending points Example: Parse error: syntax error, unexpected $ end in |
8 |
E_NOTICE |
General notifications, such as undefined variables Example: Notice: Undefined variable: p in E: \ web \ index. php on line 17 |
16 |
E_CORE_ERROR |
A fatal error occurred when the PHP process was started. Example: None |
32 |
E_CORE_WARNING |
Warning at PHP startup (non-fatal error) Example: None |
64 |
E_COMPILE_ERROR |
Fatal compile-time error Example: None |
128 |
E_COMPILE_WARNING |
Warning errors during compilation Example: None |
256 |
E_USER_ERROR |
Custom Error messages Example: None |
512 |
E_USER_WARNING |
Custom warning messages Example: None |
1024 |
E_USER_NOTICE |
Custom notification messages Example: None |
2047 |
E_ALL |
All the preceding error messages, but not the E_STRICT error messages Example: None |
2048 |
E_STRICT |
Code Standardization warning, allowing PHP to recommend how to modify code to ensure optimal interoperability forward compatibility. |
The default value of error_reporting variable is E_ALL &~ E_NOTICE
During development, the optimal value is: E_ALL | E_STRICT
If set to: error_reporting (E_ALL | E_STRICT), all error messages are recorded.
This may cause a lot of error code on the website. but it is a good thing for programmers to optimize the code. some non-fatal errors do not affect program running, but it will increase the burden on PHP.
Finally, the English version of the comparison table is displayed:
1 |
E_ERROR |
Fatal run-time errors. Errors that can not be recovered from. Execution of the script is halted |
2 |
E_WARNING |
Non-fatal run-time errors. Execution of the script is not halted |
4 |
E_PARSE |
Compile-time parse errors. Parse errors shoshould only be generated by the parser |
8 |
E_NOTICE |
Run-time notices. The script found something that might be an error, but cocould also happen when running a script normally |
16 |
E_CORE_ERROR |
Fatal errors at PHP startup. This is like an E_ERROR in the PHP core |
32 |
E_CORE_WARNING |
Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core |
64 |
E_COMPILE_ERROR |
Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine |
128 |
E_COMPILE_WARNING |
Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine |
256 |
E_USER_ERROR |
Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error () |
512 |
E_USER_WARNING |
Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error () |
1024 |
E_USER_NOTICE |
User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error () |
2048 |
E_STRICT |
Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code |
4096 |
E_RECOVERABLE_ERROR |
Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler ()) |
8191 |
E_ALL |
All errors and warnings, except T level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0) |