Error of PHP function

Source: Internet
Author: User
Tags ini modify parse error php and
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 CodeThe code is 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)//displays Run-time errors with error_reporting (e_all ^ e_notice); Error_reporting (E_all);//Show 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.