C H A P T E R  2

Exceptions and References

In this chapter, we will explore exceptions and references, two fundamental aspects of modern object-oriented programming (OOP). Exceptions are synchronous events. The word “synchronous” means that they're reactions to events in the code itself, not reactions to external events, like signals. For instance, when an operator presses Ctrl-C on the keyboard, a signal is sent to the executing program. Exceptions are used for handling errors in an orderly, standard-compliant way. When the program (or a script, in the case of PHP) attempts to perform division by zero, an exception is raised. Exceptions can be raised (or thrown) and caught. Raising an exception actually means passing the program control to ...

Get Pro PHP Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.