Return to Snippet

Revision: 38616
at January 5, 2011 23:50 by jrobinsonc


Initial Code
<?php
// funcion de errores personalizado
function nettuts_error_handler($number, $message, $file, $line, $vars){
	$email = "
		<p>An error ($number) occurred on line
		<strong>$line</strong> and in the <strong>file: $file.</strong>
		<p> $message </p>";

	$email .= "<pre>" . print_r($vars, 1) . "</pre>";

	$headers = 'Content-type: text/html; charset=iso-8859-1' . "
";

	// enviar log de errores a un Email
	error_log($email, 1, '[email protected]', $headers);

	// Si es un error demasiado critico, pararlo.
	if ( ($number !== E_NOTICE) && ($number < 2048) ) {
		die("There was an error. Please try again later.");
	}
}

// declaramos cual sera la funcion que se ejecutara cuando ocurra un error
set_error_handler('nettuts_error_handler');

// realizando un error con una variable no existente
echo $somevarthatdoesnotexist;

Initial URL
http://craftyman.net/errores-con-php-enviarlos-email/

Initial Description

                                

Initial Title
Detectar errores con PHP y enviarlos por Email

Initial Tags

                                

Initial Language
PHP