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.
In the first part of this article, I introduced you to PHP's error-handling functions, demonstrating how they could be used to control the manner in which errors are handled. I showed you how to use the error reporting functions to filter out those error types you didn't want to see, and how to use a custom error handler to catch PHP's notices and warnings. Finally, I wrapped things up with a demonstration of how a custom error handler could be used to track errors on a Web site, and write those errors to a log file for later review.
There's a lot more you can do with PHP's error-handling API, though; what you've seen so far is just the tip of the iceberg. In this concluding section, I will demonstrate how you can piggyback your code on top of PHP's core engine by triggering your own errors and writing custom handlers to deal with them. I will also show you a simpler method of logging errors, and will (as usual) put the theory to the test with a couple of real-world examples. Much mayhem ahead...so don't go anywhere!