DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Serg has posted 8 posts at DZone. View Full User Profile

PHP Error

10.08.2010
| 2263 views |
  • submit to reddit
        Error handling is an important part of creating web applications and espesially in <a href=http://conkurent.com/en/drupal-development.php>drupal development</a>. There are three different error handling methods: 

        * Simple "die()" statements
        * Custom errors and error triggers
        * Error reporting

    It’s quite simple to create a custom error handler. Just create a special function that can be called when an error occurs in PHP. 
 
error_function(error_level,error_message,
 
error_file,error_line,error_context)
A function to handle errors is shown below:
function customError($errno, $errstr)
 
  {
 
  echo "<b>Error:</b> [$errno] $errstr<br />";
 
  echo "Ending Script";
 
  die();
 
  }