Chapter 12: Error Handling and Validation


This chapter covers one of the most vital topics in web application development: how to prevent and deal with unexpected errors. Even the best-written application may fail. Whether it is due to strange user input, the failure of a remote service, or simple programmer oversight, errors and exceptions happen. Constructing a web application that can handle exceptions gracefully and meaningfully requires some additional approaches to those used in desktop applications. PHP provides both language-level and function-level mechanisms for helping the developer to construct useful exception handling.