CodeIgniter method to prohibit a Database error occurred fault hint _php instance

Source: Internet
Author: User
Tags constant php error codeigniter

By default, CodeIgniter will display all of the PHP errors. But you might want to change the situation when you end up with a development program.
You will find this function error_reporting () at the top of the index.php file, which allows you to set the error. Even if you close the error report, the error record will not stop when there is an error.
Therefore, the modification php.ini can not achieve the effect we want.

Here is the solution:

1. CodeIgniter prohibit a Database error occurred error hint

As the CodeIgniter user's guide says, setting the environment constant to ' development ' will allow all PHP error reports to be exported to the browser. Conversely, setting the constant to ' production ' will prevent all error report output.

Modify error_reporting in index.php:

Copy Code code as follows:

Define (' environment ', ' production '); 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. CodeIgniter prohibit a PHP error was encountered error hint

Modify database settings in config/database.php:

Copy Code code as follows:

$db [' Default '] [' db_debug '] = FALSE;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.