- spl_autoload_register: documentation ( source)
- var_dump: documentation ( source)
- debug_backtrace: documentation ( source)
<?php
spl_autoload_register(function($className) {
$bt = debug_backtrace(0, 2);
$bt = (isset($bt[0]["file"]) ? $bt[0] : $bt[1]); // php has an internal stack frame at [0], hhvm doesn't
echo "Loading {$className} from {$bt["file"]}:{$bt["line"]}\n";
eval("class {$className} { }");
});
var_dump(new FooClass());