Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Customizing the PHP Error Handler

By Tony Marston
2005-04-09


Introduction

One of the last areas that developers seem to deal with in their code is error handling. I am not talking here about errors with user input where it is a simple matter to display an error message and ask for new input, I am taking about the kind of error over which the user has absolutely no control and which may cause the current PHP script to stop running. In this situation you as a developer need to know some details about the error otherwise you will have a very difficult time in locating the source of the error so that you can fix it.

Developers new to PHP often complain there there is no proper error handling in the language. This is utter nonsense. All the functionality is there, you just have to customise it to your specific requirements.

In this tutorial I will show to how to create an error handler that will:

• Trap all errors whether triggered by PHP or a specific function call.
• Filter all errors depending on their error level.
• Output a formatted error message to the user.
• Send an email to the system administrator.
• Write the error details to a separate log file.


Tutorial Pages:
» Customising the PHP Error Handler
» Introduction
» Creating the Error Handler
» Calling the error handler
» Summary


 | Bookmark
Related Tutorials:
» Zend Framework Tutorial
» Port Scanning and Service Status Checking in PHP
» Web Database Access from Desktop Applications
» CubeCart 3.0 Installation and Configuration
» PHP Site Search Made Easy
» Installing and Configuring Drupal 6.1