Though every programming language offers default error handling methods. You can also write your own error handling functions in PHP.
There is a bit difference between user defined error handling method and a default error handling techniques.
In a default error handling method, program will throw a error message with filename, error message describing the error along with the line
number where error has occurred. But in a user defined error handling you can throw a well defined error message that helps you to find and
rectify error easily.
Given are the types of PHP Error Handling Functions:
In PHP die( ) method is used to handle simple and basic errors in PHP. For example if your program is not able to find or located any file or variable then it will simply die, instead of sending an error message to user.
Where as a Custom error handler or triggering is used to trigger a error when user is not entering a desirable input.
Error reporting is a method to send an error message to the user. By default PHP sends an error message to user with line number, error message and file names. But in case of using error reporting method you can send a well defined error message to users on entering a wrong data or input.
Go through the given error handling tutorial for example code.
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: PHP Error Handling Functions
Post your Comment