- spl_autoload_register: documentation ( source)
<?php
spl_autoload_register(function ($c) {
eval("class {$c} extends Exception { }");
});
try {
throw new FooException('foo');
} catch (FooException $e) {
throw new BarException('bar');
} catch (BarException $e) {
echo 'hallo!';
}