PHP Exceptions
This lesson discusses what exceptions are and how PHP allows you to handle them.
We'll cover the following
What is an Exception? #
An exception is an unexpected program result that can be handled by the program itself. Exception Handling in PHP is almost similar to exception handling in all programming languages.
What Happens When an Exception is Triggered? #
When an exception is triggered, the current code state is saved. The code execution will switch to a predefined (custom) exception handler function Depending on the situation, the handler may then resume the execution from the saved code state, terminate the script execution or continue the script from a different location in the code.
Exception Handling in PHP #
PHP provides the following specialized keywords for this purpose:
- try
- throw
- catch
- finally
In the next lesson, we will learn about these keywords in detail.
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy