Last active
September 13, 2019 08:16
-
-
Save gowon/84584b6443b2bb60da5b to your computer and use it in GitHub Desktop.
Directory-based autoload function
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 | |
/* Directories that contain classes */ | |
$classesDir = array ( | |
ROOT_DIR.'classes/', | |
ROOT_DIR.'firephp/', | |
ROOT_DIR.'includes/' | |
); | |
function __autoload($class_name) { | |
global $classesDir; | |
foreach ($classesDir as $directory) { | |
if (file_exists($directory . $class_name . '.php')) { | |
require_once ($directory . $class_name . '.php'); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment