- spl_autoload_register: documentation ( source)
- var_dump: documentation ( source)
- class_alias: documentation ( source)
<?php
spl_autoload_register(
function($classname) {
$obj = new class {
const SOME_CONST = 'foo';
// stuff...
};
class_alias(get_class($obj), $classname, false);
return $obj;
}
);
$obj = new Foo;
var_dump($obj);
echo Foo::SOME_CONST;