Error_reporting (E_ALL ^ E_NOTICE) of PHP functions

Source: Internet
Author: User
Check the connect. the first sentence in php is error_reporting (E_ALL ^ E_NOTICE). I have never paid attention to this statement before. I know it is an error message, but I am not sure how to set it. Next, I have excerpted something from the Internet and summarized it. 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

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.