- spl_autoload_register: documentation ( source)
- var_dump: documentation ( source)
- class_exists: documentation ( source)
- printf: documentation ( source)
<?php
spl_autoload_register(function($class) {
throw new Exception("Could not load $class");
});
spl_autoload_register(function($class) {
if ($class == "Widget") {
eval('class Widget { }');
}
});
spl_autoload_register(function($class) {
throw new Exception("Still could not load $class");
});
try {
new Foo();
} catch (Exception $e) {
for ($i = 1; $e; $e = $e->getPrevious()) printf("#%d Foo: %s\n", $i++, $e->getMessage());
} finally {
var_dump(class_exists("Foo", false));
}
try {
new Widget();
} catch (Exception $e) {
for ($i = 1; $e; $e = $e->getPrevious()) printf("#%d Foo: %s\n", $i++, $e->getMessage());
} finally {
var_dump(class_exists("Widget", false));
}