In this tutorial, you shall learn about different topics of Exception Handling in PHP, with the help of example programs.
PHP Exception Handling
In PHP, when something exceptional happens that compiler cannot handle, or user explicitly throws an exception, the program execution required exception handling.
The following tutorials cover some of the basic exception handling statements provided in PHP and also the most general use cases that occur when handling exceptions.
- PHP – Try Catch PHP Tutorial to explain what a try-catch statement is, how to use finally block with a try-catch statement, and some examples.
- PHP – Nested try catch PHP Tutorial to nest a try-catch statement inside another try-catch statement.
- PHP – Multiple catch blocks PHP Tutorial to write multiple catch blocks after a try block.
- PHP – Catch multiple exceptions in one catch block PHP Tutorial to write a catch block that can handle more than one exception.
- PHP – Print exception message PHP Tutorial to access exception message from the exception object.
- PHP – User defined / Custom Exception PHP Tutorial to define a custom exception, a user defined one. A custom exception is a class that extends built-in Exception class.
- PHP – Throw exception PHP Tutorial to intentionally throw an exception.