CodeIgniter Enable Disable debug mode

Today, We want to share with you CodeIgniter Enable Disable debug mode.In this post we will show you codeigniter enable error reporting, hear for codeigniter enable profiler globally we will give you demo and example for implement.In this post, we will learn about Development Environments in CodeIgniter with an example.

CodeIgniter Enable Disable debug mode

There are the Following The simple About CodeIgniter Enable Disable debug mode Full Information With Example and source code.

Also Read This πŸ‘‰   Ng-Options to Bind DropdownList using Angular Example

As I will cover this Post with live Working example to develop Error reporting and debugging in codeigniter, so the Enable/Disable debug mode in CodeIgniter for this example is following below.

disable codeigniter debug mode

class MY_Log extends CI_Log
    protected $_levels  = array('ERROR' => '1', 'INFO' => '2',  'DEBUG' => '3', 'ALL' => '4');
 * codeigniter Constructor
    public function __construct()

Error reporting handling in Codeigniter

enable displaying php errors on CodeIgniter


display_errors = ture, E_ALL, false, E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE

define('ENVIRONMENT', 'development');

Database Errors

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

Database Errors : $config[‘log_threshold’]

  $config['log_threshold'] = 1;

CodeIgniter 2+:

define('ENVIRONMENT', 'development');

CodeIgniter 3+:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');

CodeIgniter sets up error reporting

if (defined('ENVIRONMENT')) {
    switch (ENVIRONMENT) {
        case 'development':

        case 'production':

            exit('The CodeIgniter application environment is not set correctly.');


$config['base_url'] = 'http://localhost/pakainfo';


$config['base_url'] = '';


$config['base_url'] = '';

CodeIgniter index.php file

define('ENVIRONMENT', 'production'); 


$local_servers = array('localhost');
$isLocal = in_array($_SERVER['SERVER_NAME'], $local_servers);

if ($isLocal) {
    $env = 'local';
} else {
    // CodeIgniter check development word in website url
    preg_match('#/development#', $_SERVER['REQUEST_URI'], $isDevelopment);

    $env = $isDevelopment ? 'development' : 'production';

CodeIgniter Set and Get $env variable

define('ENVIRONMENT', $env);

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read This πŸ‘‰   kill process linux


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about CodeIgniter Enable Disable debug mode.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.