Exceptions in PHP
Understand the role of exceptions in PHP and their impact on functional programming principles. Learn why exceptions are considered impure and how they complicate error handling. Explore alternative methods like callbacks, default values, and sum types that enable cleaner, referentially transparent error management.
We'll cover the following...
We'll cover the following...
Exceptions feature prominently in PHP code and can be considered central to error handling in the language. Exceptions are, for all their illustrative cogency, however, impure. This chapter offers a description of exceptions, insights into the questionable purity of exceptions, and the possible alternatives to exceptions for cleaner error handling that are suitable for function composition.
Exceptions are impure
Exceptions are quite often ...