Başarısız durumda PHP bir SPL Yükleyici'ye istisnalar atmak için bir yolu var mı? PHP 5.2.11 altında çalışmak için görünmüyor.
class SPLAutoLoader{
public static function autoloadDomain($className) {
if(file_exists('test/'.$className.'.class.php')){
require_once('test/'.$className.'.class.php');
return true;
}
throw new Exception('File not found');
}
} //end class
//start
spl_autoload_register( array('SPLAutoLoader', 'autoloadDomain') );
try{
$domain = new foobarDomain();
}catch(Exception $c){
echo 'File not found';
}
Yukarıdaki kod çağrıldığında, bir istisna hiçbir işaret yerine bir standart olsun, var "Ölümcül hata: Sınıf 'foobarDomain' bla bulunamadı". Ve script yürütme sonlandırır.