Exception Handling

Exception handling deals with managing run-time errors. The process is very similar to run-time error management as covered in the preceding section. Run-time error management was the only exception handling process available prior to PHP 5.

PHP 5 exception handling was introduced by adopting into the language a set of tools familiar to C++ and Java programmers. These tools include an Exception class, try and catch blocks, and a throw operator. You will review these features of the language in the next four sections.

Using Try-Catch Blocks

The try block encloses code that can encounter an error. For every try block, there must be at least one catch block, but there can be more than one catch block. The benefit of having more ...

Get Oracle Database 10g Express Edition PHP Web 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.