Detecting all PHP errors and reporting them

[whisper]This weekend for some reason a few rows in the database were damaged (session variables, which weren’t even very important), but for several hours the site was down. I was able to fix the problem within 5 minutes, but I didn’t realize the site was down until several hours later.[/whisper]

Do you guys have any “quick scripts” that send off an email to the developer IMMEDIATELY when the first error occurs?

I have an idea of how this system can be set up, storing errors and preventing sending duplicate errors, but I have no idea how to catch ALL and ANY errors or warnings that occur.

And, if possible, in addition to knowing the error, I would like to know the error message from my PHP script without needing to browse to that page and see for myself.

All pages go through an “index.php” page before they are relayed, so adding this code would only be needed at the start of that page, rather than on each individual page.