首頁 > php教程 > php手册 > 主體

如何调整CodeIgniter的报错级别

WBOY
發布: 2016-06-13 09:39:15
原創
968 人瀏覽過

不使用CI的时候,我们可以使用 error_reporting(E_ALL); error_reporting(0); 这类的代码来控制报错级别。当然也可以在类中使用这些语句,不过CI自己已经有控制报错级别的机制在里面了。

也许你不会经常打开index.php,但是修改就在这个文件里面:

/*
 *---------------------------------------------------------------
 * APPLICATION ENVIRONMENT
 *---------------------------------------------------------------
 *
 * You can load different configurations depending on your
 * current environment. Setting the environment also influences
 * things like logging and error reporting.
 *
 * This can be set to anything, but default usage is:
 *
 *     development
 *     testing
 *     production
 *
 * NOTE: If you change these, also change the error_reporting() code below
 *
 */
	define('ENVIRONMENT', 'development');
/*
 *---------------------------------------------------------------
 * ERROR REPORTING
 *---------------------------------------------------------------
 *
 * Different environments will require different levels of error reporting.
 * By default development will show errors but testing and live will hide them.
 */

if (defined('ENVIRONMENT'))
{
	switch (ENVIRONMENT)
	{
		case 'development':
			error_reporting(E_ALL);
		break;
	
		case 'testing':
		case 'production':
			error_reporting(0);
		break;

		default:
			exit('The application environment is not set correctly.');
	}
}
登入後複製

ENVIRONMENT 就是来控制报错级别的,默认的有三个选项,development testing production,由上面的switch语句控制。代码已经很清楚了,可以根据自己的需求进行相应更改。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!