php function error_reporting (e_all ^ e_notice) detailed _php tutorial

Source: Internet
Author: User
Tags parse error
To illustrate:

In the Windows environment: Originally in the php4.3.0 running a normal program, in 4.3.1 why many error, the general tip is: notice:undefined varialbe: variable name.
For example, the following code:
Copy CodeThe code is as follows:
if (! $tmp _i) {
$tmp _i=10;
}

Running normally in 4.3.0, running in 4.3.1 will prompt notice:undefined varialbe:tmp_i
Under the question:
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

http://www.bkjia.com/PHPjc/323729.html www.bkjia.com true http://www.bkjia.com/PHPjc/323729.html techarticle Example: In the Windows environment: Originally in the php4.3.0 running a normal program, in 4.3.1 why many error, the general tip is: notice:undefined varialbe: variable name. For example, like ...

  • Related Article

    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.