How to set error level and control error in PHP [go]

Source: Internet
Author: User
Tags parse error

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.