PHP function error_reporting (E_ALL ^ E_NOTICE) detailed description

In the Windows environment: the program that originally ran normally in php4.3.0, why many errors are reported in 4.3.1, the general prompt is: Notice: Undefined varialbe: variable name. 
For example, there is the following code: 
copy code code show as below:

if (!$tmp_i) { 
$tmp_i=10; 


It runs normally in 4.3.0, and it will prompt Notice: Undefined varialbe: tmp_i when running in 4.3.1. 
Next: 
1. Where is the problem? 
2. How should this code be modified? 
3. Without changing the code, how to modify the settings in php.ini to make the original program in 4.3.0 run normally in the environment of 4.3.1? This error message will not appear. 

Solution: 

Add a sentence at the beginning of the program: 
error_reporting(E_ALL & ~E_NOTICE); or error_reporting(E_ALL ^ ​​E_NOTICE); 

or 
modify php.ini 
error_reporting = E_ALL & ~E_NOTICE 

about the error_reporting() function: 


error_reporting() sets the error level of PHP and returns the current level. 

; Error reporting is bitwise. Or add up the numbers to get the desired error reporting level. 
; E_ALL - all errors and warnings 
; E_ERROR - fatal runtime errors 
; E_WARNING - runtime warnings (non-fatal errors) 
; E_PARSE - compile-time parsing errors 
; E_NOTICE - runtime alerts (often your code Caused by bugs, 

; can also be caused by intentional behavior (eg: 
              using an uninitialized variable based on the fact that the uninitialized variable is automatically initialized to a ; empty string) 

; E_CORE_ERROR - a fatal error during PHP startup initialization 
; E_CORE_WARNING - a warning during PHP startup initialization (non-fatal) 
; E_COMPILE_ERROR - a compile-time fatal error 
; E_COMPILE_WARNING - a compile-time warning (non-fatal) Error) 
; E_USER_ERROR - user-generated error message 
; E_USER_WARNING - user-generated warning message 
; E_USER_NOTICE - user-generated reminder message 

Usage: 

error_reporting(0);//Disable error reporting 
error_reporting(E_ALL ^ ​​E_NOTICE);//display All error messages except E_NOTICE 
error_reporting(E_ALL^E_WARNING^E_NOTICE);//Display all error messages except E_WARNING E_NOTICE 

error_reporting(E_ERROR | E_WARNING | E_PARSE);//Display runtime errors, the same effect as error_reporting(E_ALL ^ ​​E_NOTICE); error_reporting(E_ALL);//Display all errors

error_reporting(E_ALL || ~E_NOTICE);//It should also display all errors

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325636660&siteId=291194637