catch Exception from __autoload
check this workaround :
<?php
function __autoload($name){
if (@!fopen($name.".php5","r")){
eval("class $name { function __construct(){throw new Exception('$name is not found');}}");
}
else {
require_once($name.".php5");
echo "\n".$name." loaded";
}
}
try{
$n = new NonExistantClass();
}catch(Exception $e){
echo $e->getMessage();
}
try{
$a = "echo hello";
$n = new $a();
$n = new test();
}catch(Exception $e){
echo $e->getMessage();
}
?>
Do not forget to
echo ' <?php class test {} ?>' > test.php5 (this will create basic class test inside test.php5.




0 Comments:
Post a Comment
<< Home