PHP off notice error tip _php Tutorial

Source: Internet
Author: User
Tags php error
This article describes some of the ways to turn off notice errors in PHP, but it's important to say that when you turn off the error message, a large number of notice level errors in your program code can cause PHP performance to degrade.

PHP notice:undefined Variable
PHP notice:undefined Index
Look, you have a variable that is not defined and is used directly. However, when compiling PHP is not as strict as C + +, when programming often use this feature. The default setting for PHP is to display these prompts, which will cause the page to not display properly.

The code is as follows Copy Code

Error_reporting (E_all);
Error_reporting (E_all | | ~e_notice); Show all error messages except E_notice

The first one is to represent all errors,

The second delegate shows that all errors do not show a warning,

We just put the second line in front of the//, the first line in front of//remove it.

Attached: detailed report of individual error reports

How to use:

The code is as follows Copy Code

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


Instance

The code is as follows Copy Code

if (! $a) {
error_reporting (0);
Ob_start (' Ob_gzhandler ');
} else {
Error_reporting (e_all ^ e_notice);
}


Prohibit modification of methods in php.ini


1, by the space quotient in the server php.ini configuration file modification:

Change the error_reporting in the php.ini file

Switch

The code is as follows Copy Code
error_reporting = E_all & ~e_notice

If you are a United States space user, unable to manipulate the php.ini file, you can use the following method to implement

2. Add the following code to the page where you want to disable notice error prompts

The code is as follows Copy Code

/* Report all errors except E_notice */
Error_reporting (e_all ^ e_notice);

The point is that


Closing the PHP error output does not shut down the PHP kernel's handling of the error, and if there is a large number of notice-level errors in the code, it will degrade the performance of the PHP program. So when we're developing, we're going to turn the error level to E_all and handle every unreasonable code carefully.

http://www.bkjia.com/PHPjc/631601.html www.bkjia.com true http://www.bkjia.com/PHPjc/631601.html techarticle This article describes some of the ways to turn off notice errors in PHP, but it's important to say that when you turn off the error, there's a lot of notice-level errors in your program code that will cause PHP performance ...

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