Home > Backend Development > PHP Tutorial > How to send PHP errors by email, send php_PHP tutorial by email

How to send PHP errors by email, send php_PHP tutorial by email

WBOY
Release: 2016-07-13 09:46:05
Original
719 people have browsed it

How to send PHP errors via email, send php via email

The example in this article describes the method of sending PHP errors via email. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
// Our custom error handler
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 class="brush:php;toolbar:false">" . print_r($vars, 1) . "
"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Email the error to someone... error_log($email, 1, 'you@youremail.com', $headers); // Make sure that you decide how to respond to errors (on the user's side) // Either echo an error message, or kill the entire project. Up to you... // The code below ensures that we only "die" if the error was more than // just a NOTICE. if ( ($number !== E_NOTICE) && ($number < 2048) ) { die("There was an error. Please try again later."); } } // We should use our custom function to handle errors. set_error_handler('nettuts_error_handler'); // Trigger an error... (var doesn't exist) echo $somevarthatdoesnotexist;
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1035662.htmlTechArticleHow to send PHP errors by email, send php by email. This article describes the method of sending PHP errors by email. Share it with everyone for your reference. The specific implementation method is as follows: php// O...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template