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

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

尚
forward
2020-03-09 10:29:392871browse

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);
}

Dreamweaver

include/common.inc.php

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete