Welcome Guest, Not a member yet? Register   Sign In
CLI with MY_Controller subclassing causing __autoload error
#1

[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?




Theme © iAndrew 2016 - Forum software by © MyBB