PHP error message shutdown Methods

Source: Internet
Author: User

The simplest way is to add the following code directly to the php program code:

Copy codeThe Code is as follows: error_reporting (E_ALL ^ E_NOTICE ^ E_WARNING );

Disable all notice and warning errors.

Put this statement in the function inclusion file of your script, which is usually controlled by config. php or conn. php.

Of course, I can also set it in php. ini as follows:

Open the PHP. ini file in the php installation directory.

Find display_errors = On and change it to display_errors = off.

Note: If you have copied the PHP. ini file to the windows directory, you must change display_errors = On in c: windows/php. ini to display_errors = off.

Solution for failure of display_errors = Off in PHP. ini

Problem:

In the PHP setting file php. ini, display_errors = Off is already set, but an error message still appears on the webpage during running.

Solution:

Open the PHP. ini file in the php installation directory.

Find log_errors = off and change it to log_errors = on.

Find error_log = filename and change it to error_log = "D: PHPerrlogphp_error.log" (here, the directory and file name D: PHPerrlogphp_error.log are whatever you want)

Note: If you have copied the PHP. ini file to the windows directory, you must also copy the c: windows/php. ini file.

In addition, php_error.log must have at least the USER's modification and write permissions. Otherwise, the error log cannot be output.

Often seen error_reporting (7) meaning: Set the error message return level.

Value constant
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
64 E_COMPILE_ERROR
128 E_COMPILE_WARNING
256 E_USER_ERROR
512 E_USER_WARNING
1024 E_USER_NOTICE
2047 E_ALL
2048 E_STRICT

However, 7 = 1 + 2 + 4
1 E_ERROR 2 E_WARNING 4 E_PARSE is displayed when an error occurs.

Copy codeThe Code is as follows: <? Php
// Disable Error Reporting
Error_reporting (0 );
// Report running errors
Error_reporting (E_ERROR | E_WARNING | E_PARSE );
// Report all errors
Error_reporting (E_ALL );
?>

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.