Introduced in PHP 5, exceptions are a critical part of any OOP application. The term exception refers to the entire machinery of
throw statements, and the
Exception class. This machinery is designed to help you define when a problem occurs and what the code should do when a problem is encountered.
Exceptions give you control over how your program generates and handles errors. Exceptions also make your programming life easier by providing details about the context of the exception. By using exceptions, you will be able to create more robust applications that are fault-tolerant and that can inform an administrator when problems arise.
In this chapter, I will show you how to use built-in exceptions, as well as ...