首页 > 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学习者快速成长!