Welcome Guest, Not a member yet? Register   Sign In
Autoload function
#2

For auto loading of base controller classes in core folder.

Can be modified to load other folders as well.

PHP Code:
// -----------------------------------------------------------------------

/**
 * Our SPL Autoloader.
 * -----------------------------------------------------------------------
 *
 * Add to the bottom of your ./application/config/config.php file.
 * 
 * Autoload Classes that are in the ./application/core folder.
 * 
 * Used to autoload base controller classes etc;
 */
spl_autoload_register(function ($class) {

    if (
strpos($class'CI_') !== 0)
    {
        if (
is_readable(APPPATH.'core/'.$class.'.php'))
        {
            require_once(
APPPATH.'core/'.$class.'.php');
        }
    }

}); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Autoload function - by Skinper - 02-24-2019, 06:23 AM
RE: Autoload function - by InsiteFX - 02-24-2019, 09:22 AM
RE: Autoload function - by Skinper - 02-24-2019, 02:59 PM
RE: Autoload function - by dave friend - 02-24-2019, 04:01 PM
RE: Autoload function - by Skinper - 02-25-2019, 10:19 AM
RE: Autoload function - by dave friend - 02-25-2019, 05:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB