August 2013
Intermediate to advanced
140 pages
1h 49m
English
CHAPTER 30
![]()
Exception Handling
PHP 5 introduced exceptions, a built-in mechanism for handling program failures within the context in which they occur. Unlike errors, which generally need to be fixed by the developer, exceptions are handled by the script. They represent an irregular run-time situation that should have been expected as a possibility, and which the script should be able to handle on its own.
Throwing exceptions
When a situation occurs that a function cannot recover from it can generate an exception to signal to the caller that the function has failed. This is done using the throw keyword followed by a new instance of the Exception ...
Read now
Unlock full access