Created
November 10, 2015 15:52
-
-
Save rochellelewis/55946dfb6f544b52870e to your computer and use it in GitHub Desktop.
Class Autoloader
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
<?php | |
/** | |
* Class Autoloader | |
* stolen from Skyler | |
* sin verguenza | |
* | |
* @author Skyler Rexroad | |
*/ | |
spl_autoload_register("Autoloader::classLoader"); | |
class Autoloader { | |
/** | |
* This function autoloads classes if they exist | |
* | |
* @param string $className name of class to load | |
* @return bool false if classes can not be loaded | |
**/ | |
public static function classLoader($className) { | |
$className = strtolower($className); | |
if(is_readable(__DIR__ . "/$className.php")) { | |
require_once(__DIR__ . "/$className.php"); | |
} else { | |
return(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the above file to your /classes directory.
Then at the top of each of your class files:
require_once("autoload.php");