In this chapter, we will explore exceptions and references, two fundamental aspects of modern objectoriented 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 the part of the program designed to deal with those events. Modern programming languages such as PHP have means of doing that in a logical and ordered way.
Unable to display preview. Download preview PDF.