CodeIgniter Forums
CLI with MY_Controller subclassing causing __autoload error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CLI with MY_Controller subclassing causing __autoload error (/showthread.php?tid=57245)



CLI with MY_Controller subclassing causing __autoload error - El Forum - 02-28-2013

[eluser]jmadsen[/eluser]
Hey all,

I am using v2.1.1

I have the following code at the bottom of my config/config.php to allow me to subclass off of MY_Controller

Code:
function __autoload($class)
{  
    /* don't autoload CI_ prefixed classes or those using the config subclass_prefix */
    if (strstr($class, 'CI_') OR strstr($class, config_item('subclass_prefix'))) return;

    /* autoload core classes */
    if(is_file($location = APPPATH.'core/'.$class.EXT))
    {
       include_once $location;
       return;
    }  
  
    /* autoload library classes */
    if(is_file($location = APPPATH.'libraries/'.$class.EXT))
    {
       include_once $location;
       return;
    }  
}

Site is fine when viewed through browser normally. I need to set up a couple of cron jobs, but when I try to run a simple:

Code:
php index.php testing test_cli

I'm getting an error:

Fatal error: Cannot redeclare __autoload() previously declared in config/config.php line ...

It points to the function I posted above

Any thoughts on what might be going on?