- class_exists: documentation ( source)
<?php
if (!class_exists('Error', false)) {
// We can't really avoid making this extend Exception in PHP 5.
class Error extends Exception
{
}
}
if (!class_exists('TypeError', false)) {
class TypeError extends Error
{
}
}
try {
throw new TypeError("Blah");
/* } catch ( TypeError $e ) {
die( 'TypeError' );
} catch ( Error $e ) {
die( 'Error' );*/
} catch ( Exception $e ) {
die( 'Exception' );
}