Home > Backend Development > PHP Tutorial > How to adjust CodeIgniter's error reporting level_PHP tutorial

How to adjust CodeIgniter's error reporting level_PHP tutorial

WBOY
Release: 2016-07-13 10:34:07
Original
759 people have browsed it

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.');
	}
}
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template