Manipulador de erros personalizado

Manipulador de erros personalizado que envia por e-mail os detalhes dos erros em vez de exibi-los no navegador.

<?
set_error_handler
('error_handle');

function error_handle($errno, $errstr, $errfile, $errline){
// The email address to send the email to
$mail_to
= 'developers@test.com';

// The email address the email comes from
$mail_from
= 'errors@test.com';

// Extract the visitor's browser information
$browser
= get_browser(null,true);

// Setup the content of the email
$mail_text
= 'Error '.$errno.' in '.$errfile.' (line '.$errline.'):'."rn".$errstr."rn"."rn";
$mail_text
.= 'Current URL: '.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']."rn";
$mail_text
.= 'Visitor IP: '.$_SERVER['REMOTE_ADDR']."rn";
$mail_text
.= 'Visitor Browser: '.$browser['browser'].' '.$browser['version'].' ('.$browser['platform'].')';

// Configure the email headers
$mail_headers
= 'From: '.$mail_from."rn".'X-Mailer: PHP/'.phpversion();

// The subject of the email
$mail_subject
= 'Error';

// Send the email
@mail($mail_to, $mail_subject, $mail_text, $mail_headers);
}
?>