News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

What is an Exception in PHP

Started by sajiv, Aug 13, 2008, 05:33 PM

Previous topic - Next topic

sajiv


With PHP 5 came a new object oriented way of dealing with errors.

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:

*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

We will show different error handling methods:
*Basic use of Exceptions
*Creating a custom exception handler
*Multiple exceptions
*Re-throwing an exception
*Setting a top level exception handler

Note: 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.

:acumen