Of course, this is just my first stab at a generic error reporting class. It's designed for very simple requirements, and may be way too primitive for your needs. If this is the case, you have two basic options:
If, on the other hand, you're lazy and figured that door two was more promising, you'll be happy to hear that the Web has a huge number of powerful error handling classes floating around it, many of them extremely powerful. Here are two that looked particularly interesting: Gyozo Papp's ErrorHandler class, at http://gremlins.mirrors.phpclasses.org/browse.html/package/345.html Lennart Groetzbach's debugHelper class, at http://gremlins.mirrors.phpclasses.org/browse.html/package/891.html You can also read more about the material discussed in this article, at the following links: PHP output control functions, at http://www.php.net/manual/en/ref.outcontrol.php PHP error handling functions, at http://www.php.net/manual/en/ref.errorfunc.php Classes in PHP, at http://www.php.net/manual/en/language.oop.php And that's about all for the moment. In this article, you expanded your knowledge of PHP's OOP capabilities by actually using all that theory to build something useful - an error reporting widget which can be wrapped around your PHP scripts to provide consistent and reusable error messages without breaking your Web pages. If you're a stressed-out Web developer working on a Web site or application, you might find this object a handy tool in your next development effort. If you're a novice programmer struggling to understand how OOP can make your life easier, I hope this article offered some pointers, as well as some illustration of how object-oriented programming works. And if you don't fit into either of those categories - well, I hope you found it interesting and informative, anyway. See you soon! Note: All examples in this article have been tested on Linux/i586 with PHP 4.2.3. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!
blog comments powered by Disqus |