http://ru2.php.net/manual/en/function.set-error-handler.php котеров даже создал целуй "библиотеку" для этих целей ;)