Home >Backend Development >PHP Tutorial >PHP sends error message via Eamil_PHP tutorial

PHP sends error message via Eamil_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:32:40892browse

PHP sends error messages through Eamil emails. I don’t think it is very commonly used, but as I often work on PHP projects, I will keep it for future reference.

view sourceprint?01

 02//Custom handler

 03function nettuts_error_handler($number, $message, $file, $line, $vars){

 04 $email = "

 05

 An error ($number) occurred on line

 06 $line and in the file: $file.

 07

$message

 ";

 08 $email .= "

 " . print_r($vars, 1) . "

 ";

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

 10 error_log($email, 1, 'you@youremail.com', $headers);

 11 if ( ($number !== E_NOTICE) && ($number < 2048) ) {

 12 die("There is an error, please try again later!.");

 13}

 14}

 15set_error_handler('nettuts_error_handler');

 16echo $somevarthatdoesnotexist;

 17?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/755613.htmlTechArticlePHP sends error messages through Eamil emails. I don’t think it is very common, but as I often work on PHP projects, I will keep it for now. Please refer to it later. view sourceprint?01 02//Custom handler 03fun...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn