php - How can I suppress a notice error in codeigniter? -


i want suppress notices in codeigniter error log during cronjob. i've tried using @ in front of line, still prints notice in log:

this row generating notice:

@$resultarray[1][2]++; 

the notice: ... severity: notice --> undefined offset: 1 ...

what doing wrong here?

(i'm using overthought, please no messages claiming not use @, :) )

to have php report errors except e_notice, call php error_reporting function so:

error_reporting(e_all & ~e_notice); 

i believe best way configure index.php @ root of application first detect application environment , conditionally set php errors reported.

index.php

if (defined('environment')) {   switch (environment)   {     case 'development':     case 'testing':     case 'staging':       error_reporting(e_all & ~e_notice);     break;      case 'production':       error_reporting(0);     break;      default:       exit('the application environment not set correctly.');   } } 

see official php documentation error_reporting function more configuration options.

alternatively, can call error_reporting function in particular file you're using (whatever cron job calls) , it'll overwrite configuration set in index.php. here's simple example using controller:

class sample_controller extends ci_controller {    public function __construct()   {     parent::__construct();     error_reporting(e_all & ~e_notice);   }  } 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -