Home > PHP Framework > YII > body text

yii error reporting level

藏色散人
Release: 2020-01-09 10:41:18
Original
2680 people have browsed it

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

The above is the detailed content of yii error reporting level. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!