PHP error_reporting (e_all ^ e_notice) Error Report detailed description _php tutorial

Source: Internet
Author: User
Tags parse error
This article describes in detail the php,error_reporting, error report php error_reporting (e_all ^ e_notice) Open and close the error tips of some of the methods summarized, the need for a friend to refer to.

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:

The code is as follows Copy Code
if (! $tmp _i) {
$tmp _i=10;
}

Running normally in 4.3.0, running in 4.3.1 will prompt notice:undefined varialbe:tmp_i

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 run normally without this error.

Workaround:


Open the php.ini file in the PHP installation directory

Find display_errors = on modified to Display_errors = Off
Note: If you have copied the php.ini file to the Windows directory, you must also change the Display_errors = on in C:windows/php.ini to Display_errors = Off

Two ways to let the script error prompt output as a log file:

Open the php.ini file in the PHP installation directory
Find log_errors = off modified to Log_errors = On
Find error_log = filename modified to error_log= "D:phperrlogphp_error.log" (Here's the directory and filename d:phperrlogphp_error.log whatever you take)
Note: If you have copied the php.ini file to the Windows directory, you must also put the C:windows/php.ini file.
In addition Php_error.log must have user's modify and write permission at least, otherwise cannot output error log.

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 by intentional behavior). (e.g., using an uninitialized variable based on the fact that an uninitialized variable is automatically initialized to an empty string)
; 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


Can I turn off the error message for PHP? I do not want to let others see my program error.

Question Answer:
Because the settings in php.ini are global, we cannot modify the configuration information directly for a single user, but you can adjust the error message output of the script you are running by error_reporting this PHP function, for example:

The code is as follows Copy Code

Error_reporting (e_all^e_notice^e_warning);

You can turn off all notice and warning levels of errors.

Put this statement in your script's function include file, usually in config.php or conn.php to control the output.

The code is as follows Copy Code
disabling error Reporting
error_reporting (0);
Report Run-time errors
Error_reporting (E_error | e_warning | E_parse);
Report All Errors
Error_reporting (E_all);
?>

http://www.bkjia.com/PHPjc/444671.html www.bkjia.com true http://www.bkjia.com/PHPjc/444671.html techarticle This article describes in detail the php,error_reporting, error report php error_reporting (e_all ^ e_notice) Open and close the error tips of some of the methods summarized, the need for friends can refer to a ...

  • 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.