Home > Backend Development > PHP Tutorial > Introduction to how to turn on and off error prompts in php

Introduction to how to turn on and off error prompts in php

Release: 2023-04-08 13:00:01
forward
2956 people have browsed it

Introduction to how to turn on and off error prompts in php

There are two ways to turn on and off the php error prompt. One is to set it in the php.ini configuration file. The other is to use the functions ini_set() and error_reporting() in the php file.

Recommendation: "php Training"

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.)All errors

E_ALL & ~E_NOTICE (Show all errors, except for notices) In addition to notifications, all errors

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

ini_set('display_errors','off');Turn off error prompts.

ini_set('display_errors','on');Open error prompt.

error_reporting(E_ALL & ~E_NOTICE) sets the error level.

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

For more programming related content, please pay attention to the Programming Tutorial column of the php Chinese website!

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

Related labels:
php
source:csdn.net
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template