CHAPTER 4Exceptions

Introduced in PHP 5, exceptions are a critical part of any OOP application. The term exception refers to the entire machinery of try, catch, and 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 ...

Get Pro PHP: Patterns, Frameworks, Testing and More now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.