通过Email发送 php错误的方法示例代码

怪我咯
发布: 2023-03-13 07:00:01
原创
1057 人浏览过

这篇文章主要介绍了通过Email发送PHP错误的方法,实例分析了php错误的读取及通过php发送Email的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了通过Email发送PHP错误的方法。分享给大家供大家参考。具体实现方法如下:

<?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;
登录后复制

以上是通过Email发送 php错误的方法示例代码的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!