PHP Exceptions
Handling errors gracefully.
PHP Exceptions
An exception is an object that describes an error or unexpected behavior of a PHP script.
Exceptions are thrown by many PHP functions and classes.
Throwing an Exception
The throw statement allows a user defined function or method to throw an exception.
Try...Catch...Finally
To catch exceptions, we use the try...catch statement. Code that may throw an exception is surrounded by a try block. Exception handling code is surrounded by a catch block. Code that runs regardless is in finally.