Home  >  Article  >  Backend Development  >  How to disable A Database Error Occurred error prompt in Codeigniter_PHP Tutorial

How to disable A Database Error Occurred error prompt in Codeigniter_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:28:281212browse

By default, CodeIgniter will display all PHP errors. But at the end of your development process, you may want to change this situation.
You will find this function error_reporting() at the top of the index.php file, through which you can set errors. Even if you turn off error reporting, error logging will not stop when an error occurs.
So, modifying php.ini cannot achieve the effect we want.

Here’s the solution:

1. A Database Error Occurred error prompt is prohibited in Codeigniter

As stated in the CodeIgniter User Guide, setting the ENVIRONMENT constant to the 'development' value will allow all PHP error reports to be output to the browser. Conversely, setting the constant to 'production' will suppress the output of all error reports.

Modify error_reporting in index.php:

Copy the code The code is as follows:

define( 'ENVIRONMENT', 'production'); //The default is development
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.');
}
}


2. A PHP Error was encountered error is prohibited in Codeigniter Tips Modify the database settings in config/database.php:


Copy the code The code is as follows:
$db['default ']['db_debug'] = FALSE;

http://www.bkjia.com/PHPjc/788625.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/788625.htmlTechArticleBy default, CodeIgniter will display all PHP errors. But at the end of your development process, you may want to change this situation. You will find this at the top of the index.php file...
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