In a Windows environment: Sometimes a program that runs normally in another environment will report an error in its own environment Undefined index: such errors
For example, the following code:
Undefined Varialbe:
Here is the solution found online:
The problem is as follows:
1. Where is the problem?
2. How should I modify this code?
3. Do not change the paragraph code, how to modify the settings in the php.ini so that the original program in the 4.3.0 in the 4.3.1 environment to operate normally? This error does not occur.
Workaround:
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 for PHP and returns the current level.
; The error report is bitwise. Or add up the numbers to get the error report level you want.
; E_all-All errors and warnings
; E_error-Fatal Run-time error
; E_warning-run-time warning (non-fatal error)
; E_parse-Compile-time parse error
; E_notice-Runtime Reminders (these are often caused by bugs in your code,
, or it may be intentional behavior. (for example, an uninitialized variable is automatically initialized to a
The fact of an empty string uses an uninitialized variable)
; E_core_error-fatal error occurred during initialization of PHP startup
; E_core_warning-Warning (non-fatal error) occurred during initialization of PHP startup
; E_compile_error-Compile-time fatal error
; E_compile_warning-Compile-time warning (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
How to use:
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);//Displays all error messages except e_warning E_notice
Error_reporting (E_error | e_warning | E_parse);//Display run-time errors with error_reporting (e_all ^ e_notice); Error_reporting (E_all);//Show All errors
Transfer from URL _______ http://blog.sina.com.cn/s/blog_a345735b0100zy53.html