Home  >  Article  >  Backend Development  >  How to adjust CodeIgniter’s error reporting level_PHP tutorial

How to adjust CodeIgniter’s error reporting level_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:07723browse

When CI is not used, we can use codes such as error_reporting(E_ALL); error_reporting(0); to control the error level. Of course, you can also use these statements in classes, but CI itself already has a mechanism to control the error level.

Maybe you don’t open index.php often, but the modifications are in this file:

/*
 *---------------------------------------------------------------
 * 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 is used to control the level of error reporting. There are three default options, development testing and production, which are controlled by the switch statement above. The code is already clear and can be changed accordingly to suit your needs.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/752348.htmlTechArticleWhen CI is not used, we can use code like error_reporting(E_ALL); error_reporting(0); Control the error level. Of course, you can also use these statements in classes, but CI itself...
Statement:
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