I’m using codeigniter. Suddenly, for some reason, my application/config/config.php started loading twice.
I have the following code at the top of config file, starts from line 5 to line 12:
function __autoload ($class) {
$file = APPPATH . 'libraries/' . $class . EXT;
if (strpos($class, 'CI_') !== 0) {
if (file_exists($file) && is_file($file)) {
@include_once (APPPATH . 'libraries/' . $class . EXT);
}
}
}
When i test a page, i get this error:
Fatal error: Cannot redeclare __autoload() (previously declared in C:\xampp\htdocs\ci_centric\application\config\config.php:5) in C:\xampp\htdocs\ci_centric\application\config\config.php on line 12
If i wrap the autoload with if(!function_exists('__autoload')) { ... }, i get the following output:
Notice: Constant FRONTEND_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 390
Notice: Constant FRONTEND_WEBPARTS_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 391
Notice: Constant FRONTEND_MAINPAGES_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 392
Notice: Constant BACKEND_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 393
Notice: Constant BACKEND_WEBPARTS_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 394
Notice: Constant BACKEND_MAINPAGES_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 395
Notice: Constant BACKEND_MAINPAGES_PATH already defined in C:\xampp\htdocs\ci_centric\application\config\config.php on line 396
.
.
.
Everything used to work fine for days; i played little bit with $this->session->flashdata(‘…’); then i got the config double loading problem.
Any help will be appreciated…
Well, I don’t know what kind of hacks do you use, and WHY do you do such things in a
configurationfile, where only variables should be declared. You should remove that code or better even start from a fresh copy of CodeIgniter. You don’t know where and for what purpose CodeIgniter wants to load this file twice. Anyway, you should not do such things by any means. If it’s really necessary for some awkward reason, you can try moving this toMY_core.phpor evenindex.phpfile, it’s still will be totally wrong, but much better than what you have right now.