Home  >  Article  >  PHP Framework  >  yii error reporting level

yii error reporting level

藏色散人
藏色散人Original
2020-01-09 10:41:182649browse

yii error reporting level

yii Error reporting level

php sets the error reporting level, and the project backend is developed using the YII framework

Recommended learning: yii framework

The requirement is that when using map['key'] to obtain the element value, if the key value does not exist, no error will occur. Adjust the error reporting level of the online backend to the lowest level:

Solution:

(1) At the beginning of the project’s entry file, add the line of code error_reporting(E_ALL^E_NOTICE); .

(2) Open the php.ini configuration file and set error_reporting=E_ALL & ~E_NOTICE

I use the first method, which takes effect immediately. The second method requires restarting the web server.

Supplement: Since the project is online, the error reporting levels must be treated differently: Generally, the error reporting level is higher during development, and after going online, the error reporting level is lower. In order to meet such requirements, it can only be set at the entry file. The code is as follows:

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
//设置报错级别
if(defined('YII_DEBUG')) {
error_reporting(E_ALL ^ E_NOTICE);
} else {
error_reporting(0);
}

The above is the detailed content of yii error reporting level. 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