Welcome Guest, Not a member yet? Register   Sign In
practical to autoload libraries like this?
#1

[eluser]ntheorist[/eluser]
in the Controller, or Controller extending class :
Code:
function __get($name)
{
    // Return return value
    if (isset($this->{$name})) return $this->{$name};
    
    // Will exit if not found
    $this->load->library($name);
    
    return $this->{$name};
}

i realize automagic php functions can be overused and not so great performance-wise, but this might work as an alternative to the autoload config. The only thing is this only loads libraries, but those tend to be the bulkiest parts of an app and would call it up only when needed. Sure its easy just to write $this->load->library() but i'm lazy! Tongue


n


Messages In This Thread
practical to autoload libraries like this? - by El Forum - 07-13-2009, 07:25 PM
practical to autoload libraries like this? - by El Forum - 07-13-2009, 08:10 PM
practical to autoload libraries like this? - by El Forum - 07-13-2009, 08:11 PM
practical to autoload libraries like this? - by El Forum - 07-13-2009, 08:14 PM
practical to autoload libraries like this? - by El Forum - 07-13-2009, 08:45 PM
practical to autoload libraries like this? - by El Forum - 07-13-2009, 09:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB