When I looked at the connect.php of Empire cms, I found that the first sentence iserror_reporting(E_ALL ^ E_NOTICE); I have never noticed this statement before. I know that it sets an error prompt, but I don’t know how. Set to use. Below I have excerpted some things from the Internet and summarized them.
Example:
UnderWindows environment: The program that was originally running normally in php4.3.0 is reporting multiple errors in 4.3.1. The general prompt is: : Notice: Undefined varialbe: variable name.
For example, the following code:
The code is as follows:
if (!$tmp_i) { $tmp_i=10; }
It runs normally in 4.3.0 and in 4.3.1 When running, it will prompt Notice:Undefined varialbe:tmp_i
Questions:
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 so that the original program in 4.3.0 can run normally in the 4.3.1 environment? 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 reportingis 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 reminders (These are often caused by bugs in your code,
; may also be caused by intentional behavior. (For example: automatic initialization of an uninitialized variable to a
;The fact that an emptystringis using an uninitialized variable)
; E_CORE_ERROR - Fatal error that occurs during the initialization process when PHP is started
; E_CORE_WARNING - Occurs when PHP is started Warning during initialization (non-fatal error)
; E_COMPILE_ERROR - Fatal error during compilation
; E_COMPILE_WARNING - Warning during compilation (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 allerror messages except E_NOTICE
error_reporting(E_ALL^E_WARNING^E_NOTICE);//Display all errors except E_WARNING E_NOTICE Information
error_reporting(E_ERROR | E_WARNING | E_PARSE);//Display runtime errors, which has the same effect as error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL);//Display all errors
The following is a detailed explanation of the function ofPHP error_reporting() error control function
Definition and usage:
error_reporting() sets the error level of PHP and returns the current level # #.
##Function syntax:error_reporting(report_level)
Running error. The error cannot be recovered and execution of the script is suspended.
2 E_WARNING Runtime warning (non-fatal error). Non-fatal runtime error, script execution will not stop. 4 E_PARSE compile-time parsing error. Parsing errors are generated only by the parser. 8 E_NOTICE Runtime reminder (These are often caused by bugs in your code, or may be caused by intentional behavior.) 16 E_CORE_ERROR Fatal error during initialization process when PHP starts . 32 E_CORE_WARNING Warning (non-fatal error) during the initialization process when PHP starts. 64 E_COMPILE_ERROR Fatal error during compilation. This is like an E_ERROR being generated by the Zend scripting engine. 128 E_COMPILE_WARNING compile-time warning (non-fatal error). This is like an E_WARNING warning generated by the Zend script engine. 256 E_USER_ERROR User-defined error message. This is like a user-defined warning message by using the PHP functiontrigger_error(Programmer sets E_ERROR)
512 E_USER_WARNING. This is like a user-defined reminder message using the PHP function trigger_error (an E_WARNING warning set by the programmer) 1024 E_USER_NOTICE. This is like a standardized warning encoded by 2048 E_STRICT using the PHP function trigger_error (an E_NOTICE set by the programmer). Allows PHP to suggest how to modify the code to ensure optimal interoperability and forward compatibility.4096 E_RECOVERABLE_ERROR Fatal error in capturing. This is like an E_ERROR, but can be caught by a user-defined handler (see alsoset_error_handler())
8191 E_ALL All errors and warnings (excluding E_STRICT) (E_STRICT will be part of E_ALL as of PHP 6.0)
The above is the detailed content of Detailed description of php error_reporting() function. For more information, please follow other related articles on the PHP Chinese website!