Error-level variable Comparison table of PHP error_reporting, errorreporting_PHP tutorial

Source: Internet
Author: User
Tags php error reporting
Error-level variable Comparison table of PHP error_reporting, errorreporting. The error-level variable Comparison table of error_reporting in PHP. the error information of errorreporting in PHP can be set using the error_reporting () function: its parameters include the error_reporting error-level variable Comparison table of the string and number PHP, errorreporting

You can use the error_reporting () function to set all 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)

What types of error reports does php error reporting have?

Error_reporting ()
There are four types of errors and warnings in php. They are:
Common function error: 1
General warning: 2
Analysis error: 4
Note (Warn the user to ignore this information, but this problem may cause some errors to your code): 8
The four digits after the information are the representative values of the information type. they are used together as the error report level. The province's report level is 7 (1 + 2 + 4), or other combinations except "comments. This level can be changed by changing the methods indicated by the error report in the php3.ini file. It can also be set by changing the php3 error report method in the user's httpd. conf file, or by using the script language function error_reporting () during running.
 

In PHP, error_reporting (0) indicates what?

Prevent PHP reports from being reported. If you do not close it, there are errors like this.

Warning: preg_match ()

Close does not appear

You can use the error_reporting () function to set the error message returned by handler in PHP: its parameters include string and number...

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.