- spl_autoload_register: documentation ( source)
- class_exists: documentation ( source)
<?php
spl_autoload_register(function ($class) {
echo 'Class: '.$class."\n";
if ($class === 'Foo') {
class Foo implements Bar {}
}
throw new RuntimeException('Class not found');
});
try {
class_exists('Foo');
} catch (RuntimeException $e) {
echo $e->getMessage();
}