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!