Error_reporting (E_ALL ^ E_NOTICE) of PHP functions. For example: in a Windows environment: for a program that was originally running normally in php4.3.0, why did multiple errors be reported in 4.3.1? the general prompt is: Notice: Undefinedvarialbe: variable name. for example:
In Windows: The program that was originally running normally in php4.3.0 has multiple errors in 4.3.1. the general prompt is: Notice: Undefined varialbe: variable name.
For example, the following code is available:
The code is as follows:
If (! $ Tmp_ I ){
$ Tmp_ I = 10;
}
Run normally in 4.3.0. when running 4.3.1, the system prompts Notice: Undefined varialbe: tmp_ I.
Question:
1. where is the problem?
2. how should I modify this code?
3. without changing the code segment, how can I modify the settings in php. ini to make the original program in 4.3.0 run normally in the 4.3.1 environment? This error message is not displayed.
Solution:
Add one 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
Related error_reporting () functions:
Error_reporting () sets the PHP error level and returns the current level.
; Error reports are reported by bit. Or add the numbers to get the expected error report level.
; E_ALL-all errors and warnings
; E_ERROR-fatal runtime error
; E_WARNING-runtime warning (non-fatal error)
; E_PARSE-parsing error during compilation
; E_NOTICE-runtime reminder (these are often caused by bugs in your code,
It may also be caused by intentional behaviors. (For example, an uninitialized variable is automatically initialized to
; Use an uninitialized variable instead of an empty string)
; E_CORE_ERROR-fatal error during PHP startup initialization
; E_CORE_WARNING-warning occurred during PHP startup initialization (non-fatal error)
; E_COMPILE_ERROR-fatal error during compilation
; E_COMPILE_WARNING-warning during compilation (non-fatal error)
; E_USER_ERROR-error message generated by the user
; 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); // displays a runtime error, which is the same as error_reporting (E_ALL ^ E_NOTICE. Error_reporting (E_ALL); // display all errors
In a Windows environment: the program that was originally running normally in php4.3.0 has multiple errors in 4.3.1. the general prompt is: Notice: Undefined varialbe: variable name. for example...