Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FileNotFoundException extends Exception{}
- function __autoload($ClassName) {
- $classPath = join(DIRECTORY_SEPARATOR, explode('\\', trim($ClassName,'\\')));
- $extentions = explode(',', spl_autoload_extensions());
- $includePaths = explode(PATH_SEPARATOR, get_include_path());
- foreach ($includePaths as $path) {
- foreach ($extentions as $ext):
- $file = $path.DIRECTORY_SEPARATOR.$classPath.$ext;
- // echo "Trying $file . . .\n";
- if (is_file($file)) {
- // echo "Found $file . . .\n\n";
- require $classPath.$ext;
- return;
- }
- endforeach;
- }
- throw new FileNotFoundException("Couldn't find $classPath using extentions: (". join('|', $extentions).').');
- }
- spl_autoload_extensions('.class.php,.php,.enum.php');
- spl_autoload_register('__autoload', true);
Advertisement
Add Comment
Please, Sign In to add comment