Created
July 13, 2011 13:55
-
-
Save olivermt/1080332 to your computer and use it in GitHub Desktop.
This file contains 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
//in my config file | |
require_once(SITE_DIR . '/class/ClassAutoLoader.php'); | |
$loader = new ClassAutoLoader(); | |
//the autoloader | |
<?php | |
class ClassAutoloader { | |
public function __construct() { | |
spl_autoload_register(array($this, 'loader')); | |
} | |
private function loader($className) { | |
include (SITE_DIR . '/class/' . $className . '.php'); | |
} | |
} | |
?> | |
/* | |
Usage: one class per file, name file the same as the class, and the autoloader will load it. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment