View difference between Paste ID: fd2ETB0r and s40bdTff
SHOW: | | - or go back to the newest paste.
1
class FileNotFoundException extends Exception{}
2
3
function __autoload($ClassName) {
4
	$classPath = join(DIRECTORY_SEPARATOR, explode('\\', trim($ClassName,'\\')));
5
	$extentions = explode(',', spl_autoload_extensions());
6
	
7
	$includePaths = explode(PATH_SEPARATOR, get_include_path());
8
	
9
	foreach($includePaths as $key=>$path) {
10
		$includePaths[$key] = rtrim($path, DIRECTORY_SEPARATOR);
11
	}
12
	
13
	foreach ($includePaths as $path) {
14
		foreach ($extentions as $ext):
15-
				require $classPath.$ext;
15+
16
//			echo "Trying $file . . .\n";
17
			if (is_file($file)) {
18
//				echo "Found $file . . .\n\n";
19
				require $file;
20
				return;
21
			}
22
		endforeach;
23-
spl_autoload_extensions('.class.php,.php,.enum.php');
23+
24
	
25
	throw new FileNotFoundException("Couldn't find $classPath using extentions: (". join('|', $extentions).').');
26
}
27
spl_autoload_extensions('.class.php,.php,.inc');
28
spl_autoload_register('__autoload', true);
29