The following article will introduce you to php error reporting levels. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
error_reporting()
is used to set the PHP error reporting level and return the current level. (PHP 4, PHP 5)
function can set the error_reporting directive at runtime.
PHP has many error levels. Use this function to set the level when the script is running.
If the optional parameter level is not set, error_reporting() will only return the current error reporting level.
Parameter level
New error_reporting level. Can be a bitmask or a named constant.
It is recommended to use named constants to ensure compatibility with future versions. Due to the addition of error levels and the increase in the range of integer values, older integer-based error levels will not always behave as expected.
level possible values (error reporting level in php)Common: about 15 in total
15 corresponds exactly to the 15 bits of binary.
It should be noted that the fields in the above table are not static. Different PHP versions may have different values. For details, please refer to PHP predefined constants
Any number of the above options They can all be connected with "OR" (using OR or |), so that all required errors of all levels can be reported.
For example, the following code turns off user-defined errors and warnings, performs certain operations, and then returns to the original error level:
Example:
E_All: Decimal is 30719, converted to binary is 111011111111111
E_NOTICE: Decimal is 8, converted to binary is 1000
~ E_NOTICE: Invert E_NOTICE, and it becomes 0111
E_ALL & ~E_NOTICE:: E_ALL and ~E_NOTICE are ANDed, and it becomes 111011111110111. When converted into decimal, it is 30711
. You can see E_ALL Not all errors are displayed. The 12th bit is 0. The weight of this bit is 2 to the 11th power, which is 2048. It is actually the value of E_STRICT, so E_ALL displays all error levels except E_STRICT.
E_ALL & ~E_NOTICE can be seen in binary, from right to left, the 4th and 12th bits are 0, the weight of the 4th bit is 2 to the third power, which is 8, which is the value of E_NOTICE , so all errors except E_STRICT and E_NOTICE are displayed.
For more related knowledge, please pay attention to
PHP Chinese websiteThe above is the detailed content of What are the error levels of php?. For more information, please follow other related articles on the PHP Chinese website!