您的位置:首页 > 编程语言 > PHP开发

如何调整CodeIgniter的报错级别

2012-02-11 00:00 906 查看
不使用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框架 CodeIgniter PHP