Error level for PHP

Source: Internet
Author: User

The error levels in PHP are:

1 E_ERROR(integer) Fatal run-time error. Such errors are generally unrecoverable situations, such as problems caused by memory allocations. The result is that the script terminates and no longer continues to run.
2 e_warning runtime warning (non-fatal error). Only the prompt is given, but the script does not terminate the run.
4 e_parse compile-time syntax parsing error. Parsing errors are generated only by the parser.
8 e_notice runtime notifications. Indicates that the script encountered a situation that might behave as an error, but there may be similar notifications in a script that can run correctly.
16 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_core_error (integer ) A fatal error occurred during PHP initialization startup. The error resembles e_ ERROR , but is generated by the core of the PHP engine. since PHP 4
32 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_core_warning (integer ) PHP initialization warnings (non-fatal errors) that occur during startup. Similar to  e_warning , but is generated by the PHP engine core. since PHP 4
64 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_compile_error (integer ) Fatal compile-time error. Similar to e_ ERROR , but is generated by the Zend scripting engine. since PHP 4
128 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_compile_warning (integer ) compile-time warning ( Non-fatal error). Similar to  e_warning , but is generated by the Zend scripting engine. since PHP 4
256 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_user_error (integer ) user-generated error message. Similar to  e_error , but it is up to the user to use PHP functions in their own code  trigger_error () to produce. since PHP 4
512 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_user_warning (integer ) user-generated warning message. Similar to  e_warning , However, it is generated by the user's own use of PHP functions in the Code  trigger_error () . since PHP 4
1024 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_user_notice (integer ) user-generated notification information. Similar to  e_notice , However, it is generated by the user's own use of PHP functions in the Code  trigger_error () . since PHP 4
2048 e_strict Enable PHP recommendations for code modifications to ensure the best interoperability and forward compatibility of your code. since PHP 5
4096 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_recoverable_error (integer ) A fatal error that can be captured. It indicates that a potentially very dangerous error has occurred, but has not yet caused the PHP engine to be in an unstable state. If the error is not captured by a user-defined handle (see  set_error_handler () ), it will become a  e_error Thus the script terminates the run. since PHP 5.2.0
8192 e_deprecated (integer) runtime notifications. When enabled, warns you about code that might not work correctly in a future release. since PHP 5.3.0
16384 < Code style= "font-family: ' Fira Mono ', ' Source Code Pro ', monospace;" >e_user_deprecated (integer ) The user produces less warning messages. Similar to  e_deprecated , However, it is generated by the user's own use of PHP functions in the Code  trigger_error () . since PHP 5.3.0
30719 E_ALL(integer) E_STRICTAll error and warning messages that go out. 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously

The error level is represented by a 2 binary value: 1111 1111 1111 111 from left to right, 1 on each bit, representing an error level

fatal error fatal: 0000 0000 0000 001 on 1
Warning warning error: 0000 0000 0000 010 Open 2
NOTICE warning: 0000 0000 0001 000 Open 8



To set the error reporting level method:1. Modify the PHP configuration file php.ini

Once this is set up, restarting the error_reporting Web server will take effect forever.
Open the configuration file php.ini and view the default values for error reporting levels error_reporting , as follows:

Error_reporting=e_all & ~e_deprecated & ~e_strict

It means to report all errors, but in addition to E_DEPRECATED E_STRICT these two kinds.
Modify it to:

Error_reporting=e_all & ~e_notice

It means to report all errors, but except for E_NOTICE this one. This is also the most commonly used error reporting level, and it does not report errors that note classes (such as those that use undefined variables).
Save and take effect after restarting the Web server.

2. Using the error_reporting () function

This mode can be applied immediately after it is set. But limited to the following area of the function call in the current script error_reporting() .

int error_reporting ([int $level])

The parameter can be an integer or a corresponding constant identifier, and it is recommended to use the form of a constant. The return value is the value of the error report level at the current position (integer value).

Note: php.ini display_errors The default value in the configuration file is on, which indicates that an error message is displayed, and if set to Off , all error prompts are turned off.

Use error_reporting(0) or add in front of the function to @ 抑制错误输出 prevent error messages from leaking sensitive information.


Common scenarios for these errors:

Deprecated now generally you use MySQL link database when you will report this, that you better use mysqli or PDO

Notice echo $a +8;

Warning When you use the include include file, a file error will return a wanrning error

Fatal error or require file, the file returns Fatal when an error occurs Erroe

Parse Error syntax errors



Error level for PHP

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.