PHP Predefined Exception
PHP predefined exceptions are the exception and error classes that ship built into the engine itself, available in every PHP installation without requiring any extension, autoloading, or namespace import. They form a class hierarchy rooted in the Throwable interface, which splits into two main branches: Exception, meant for conditions an application can reasonably anticipate and recover from, and Error, meant for problems in the program itself, such as type mismatches or calls to undefined functions, that are usually not meant to be caught during normal operation. Beyond the base Exception and Error classes, PHP and its Standard PHP Library provide a family of more specific predefined exceptions such as RuntimeException, LogicException, InvalidArgumentException, OutOfRangeException, OutOfBoundsException, LengthException, DomainException, RangeException, UnexpectedValueException, TypeError, ValueError, ArgumentCountError, ArithmeticError, and DivisionByZeroError, each documenting a narrower category of failure so that calling code can catch precisely the situations it knows how to handle. These classes evolve slightly from one PHP version to the next as new, more precise exceptions are introduced to replace generic ones, so the exact catalogue and inheritance chain should always be checked against the manual for the target PHP version rather than assumed from memory.
<?php
try {
throw new RuntimeException('one error!');
} catch (Exception $e) {
print "Caught an exception of type ".get_class($e);
}
?>