PHP error Log control (Display_errors and error_reporting)

Source: Internet
Author: User
Tags php error php error log

In PHP learning Display_errors and error_reporting are two very important parameters, in the program debugging process is not enough, the following to explain how these two error log configuration to open and close:

We know that in the production environment of the product must not be able to display errors, so:
Change display_errors = on to display_errors = Off in php.ini
or Ini_set (' display_errors ', 0);

Second, we know that PHP's error level is controlled by error_reporting, but there are a lot of people in the production environment that shut down the error message hint, like this error_reporting (0);

Error_reporting (0) This causes all error messages to not be logged, should: error_reporting = E_all & ~e_notice, as long as Display_errors = OFF, the error message will not be displayed on the page, Because the display_errors has a higher priority level.

In particular, it is important to note that:
If php.ini in log_errors= on, according to the official, then must specify the Error_log file, if not specified or the specified file does not have permission to write, then will output to the normal output channel, then also makes the display_errors The specified off fails, and the error message is printed out. The log_errors = off is OK.

In summary, error messages can also be logged in the production environment without displaying the error message:

<? PHP /* * * Record production environment error log *   */ error_reporting (e_all); Ini_set (' Display_errors ', 0); Ini_set (' Log_errors ', 1ini_set(' error_log ', ' e:\ '. Date (' y-m-d '). ' _phpddt.com.txt ');

PHP error Log control (Display_errors and error_reporting)

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.