Home > Backend Development > PHP Problem > How to turn off php error prompts

How to turn off php error prompts

藏色散人
Release: 2023-03-03 06:28:01
Original
4828 people have browsed it

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)除通知外,全部错误
Copy after login

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)设置错误级别。
Copy after login

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);
}
Copy after login

Dreamweaver

include/common.inc.php
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template