PHP Exceptions


PHP 5 provides a new object-oriented way of dealing with errors.

What Is an Exception
Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception. This is what normally happens when an exception is triggered: Exceptions should only be used with error conditions, and should not be used to jump to another place in the code at a specified point.

Basic Use of Exceptions
When an exception is thrown, the code following it will not be executed, and PHP will try to find the matching catch block. If an exception is not caught, a fatal error will be issued with an Uncaught Exception message. Proper exception code should include: