PHP error handling

December 29, 2012
Posted by admin 3:04 PM

 Error handling is very important in any programming languages. When error occurs the error message with filename ,line no is displayed on the browser. When we are creating scripts the error handling is very important .If our code have not error checking code then our code is not professional.
In PHP there are several methods of error handling.
1: Die();  statement.

2:Custom Errors and error triggers
3:Error Reporting
Die() function:
Die function is the most common function we use in our script for error handling.
If we want to display a variable from echo statement then we write

echo $variable_name;
If the variable doesn’t exists then a error occur Warning: variable_name is undefined
To avoid such type of warning we use die function

echo $varible_name;
die(‘Varible Not Found’);
This code is more professional than above code fo displaying the eror.But this type of error mechanism is not always efficient So we have some professional mechanism to handle the errors.