Home arrow PHP arrow Page 7 - Error Handling In PHP (part 2)

Back To Class - PHP

The first part of this article demonstrated basic errorhandling in PHP, explaining the various error types and illustrating theprocess of building a custom error handler. But that's just the tip ofthe iceberg - this concluding part goes a step further, showing you totrigger your own errors, and log error messages to a file, database oremail address.

TABLE OF CONTENTS:
  1. Error Handling In PHP (part 2)
  2. Raising Hell
  3. Rolling Back
  4. Turning Up The Heat
  5. Of Form And Function
  6. Buffer Zone
  7. Back To Class
  8. Endgame
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 11
April 09, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
If you're not a big fan of rolling your own code, you might find it instructive and useful to download the free, open-source ErrorHandler class from http://www.phpclasses.org/browse.html/package/345. Created by Gyozo Papp, this PHP class is a robust, full-featured error handler that can easily be integrated into your application code.

The ErrorHandler class comes with some very interesting features: the ability to dump errors to a separate console window so that your primary interface is not disrupted, to include in that error report the source code which caused the error, and to append customized error messages or variable context to the error report. Obviously, it also supports error logging (to a file, an email message, the system logger, or all three) and can catch and replace PHP's error messages with a user-defined error template.

Here's a small example of how it works - take a look at the manual included with the class for more examples and information.

report_layout('LOGGING', FILE_LOG, 'error.log'); // don't display symbol table $error->report_layout('CONTEXT', FALSE); // uncomment this to hide errors and display a customized error template // $error->set_silent(TRUE); // $error->set_silent("error.html"); // generate some errors include('non.existent.file'); mysql_connect("localhost", "baduser", "badpassword"); ?>
And here's what it looks like:



 
 
>>> More PHP Articles          >>> More By icarus, (c) Melonfire
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap

Dev Shed Tutorial Topics: