PHPit.net has this tutorial, jammed full of information and sample code to show you the steps to proper error handling in your application.
In this article I'm going to show you how to handle errors in PHP. In this article I will first take you through the basics of error handling, by catching all PHP errors with the set_error_handler() function. After that we'll have a look a new PHP 5 feature called Exceptions which can also be used to create and catch errors. At the end of the article I will show you how to trigger your own errors.
There's simple error handling, exception handling, and custom errors covered here making it a pretty comprehensive overview of the subject - and code for every step of the way.