An example is provided:
In the Windows environment: Originally in the php4.3.0 of the program, in the 4.3.1 Why many errors, the general hint is: notice:undefined varialbe: variable name.
For example, code that resembles the following:
Copy Code code as follows:
if (! $tmp _i) {
$tmp _i=10;
}
Running normally in 4.3.0, running in 4.3.1 prompts notice:undefined varialbe:tmp_i
Under the question:
1. Where is the problem?
2. How should this code be modified?
3. Do not change the code, how to modify the settings in the php.ini so that the original in the 4.3.0 program in the 4.3.1 environment to run normally? Without this error prompt.
Solution:
At the beginning of the program, add a sentence:
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 for PHP and returns the current level.
; The error report is bitwise. Or add up the numbers to get the error reporting level you want.
; E_all-All errors and warnings
; E_error-Fatal Run-time Error
; E_warning-Runtime Warning (non-fatal error)
; E_parse-Compile-time parse error
; E_notice-Run-time Reminders (these are often caused by bugs in your code,
; it could be a deliberate act. (such as: Automatically initialize an uninitialized variable to a
; the fact of an empty string uses an uninitialized variable)
; E_core_error-fatal error occurred during initialization of PHP
; E_core_warning-Warning (non-fatal error) during initialization during PHP startup
; E_compile_error-Compile-time fatal error
; E_compile_warning-compile-time warnings (non-fatal errors)
; E_user_error-user-generated error message
; E_user_warning-User generated warning message
; E_user_notice-User Generated reminder message
How to use:
error_reporting (0);/Disable Error Reporting
Error_reporting (e_all ^ e_notice);//Show all error messages except E_notice
Error_reporting (E_all^e_warning^e_notice)//shows all error messages except e_warning E_notice
Error_reporting (E_error | e_warning | E_parse)//shows Run-time errors, with error_reporting (e_all ^ e_notice), the effect is the same. Error_reporting (E_all);//Show All errors