Home>Article>Backend Development> How to turn off php error prompts

How to turn off php error prompts

藏色散人
藏色散人 Original
2020-07-23 11:11:29 4668browse

How to turn off php error prompts: 1. Find "display_errors" in "php.ini" and set the error prompt to be turned off; 2. Use the function "ini_set('display_errors','off');" Close the error message.

How to turn off php error prompts

php turns on and off error prompts

There are two ways to turn on and off php error prompts, one is in Set in the php.ini configuration file. The other is to use the functions ini_set() and error_reporting() in the php file.

Recommendation: "PHP Tutorial"

1. Find display_errors in php.ini, set the error prompt on and off, turn it off when it is off, and turn it on when it is on. At the same time, set the value of error_reporting to represent the level of the error.

Some common values

E_ALL (Show all errors, warnings and notices including coding standards.)全部错误 E_ALL & ~E_NOTICE (Show all errors, except for notices)除通知外,全部错误

2. If the php.ini file cannot be modified, php also provides related functions for dynamic configuration.

ini_set('display_errors','off');关闭错误提示。 ini_set('display_errors','on');打开错误提示。 error_reporting(E_ALL & ~E_NOTICE)设置错误级别。

Some commonly used frameworks or cms systems use these two functions to control the display of PHP errors.

Realization in Weiqing

define('DEVELOPMENT', $_W['config']['setting']['development'] == 1); if(DEVELOPMENT) { ini_set('display_errors', '1'); error_reporting(E_ALL ^ E_NOTICE); } else { error_reporting(0); }

Dreamweaver

include/common.inc.php

The above is the detailed content of How to turn off php error prompts. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn