Created
April 22, 2013 14:41
-
-
Save ilyabrin/5435595 to your computer and use it in GitHub Desktop.
Autoload Classes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * PHP Autoloader | |
| * */ | |
| class CAutoloader | |
| { | |
| public static $loader; | |
| public static function init() | |
| { | |
| if (self::$loader == NULL) | |
| self::$loader = new self(); | |
| return self::$loader; | |
| } | |
| public function __construct() | |
| { | |
| spl_autoload_register(array($this, 'controller')); | |
| } | |
| public function controller($className) | |
| { | |
| $className = preg_replace('#_#', '\\', $className); | |
| set_include_path(PROJECT_ROOT); | |
| spl_autoload_extensions('.php'); | |
| spl_autoload($className); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment