通过Email发送PHP错误的方法

yipeiwu_com6年前PHP代码库

本文实例讲述了通过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>" . print_r($vars, 1) . "</pre>";
  $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;

希望本文所述对大家的php程序设计有所帮助。

相关文章

php官方微信接口大全(微信支付、微信红包、微信摇一摇、微信小店)

微信入口绑定,微信事件处理,微信API全部操作包含在这些文件中。 内容有:微信摇一摇接口/微信多客服接口/微信支付接口/微信红包接口/微信卡券接口/微信小店接口/JSAPI <...

PHP 截取字符串函数整理(支持gb2312和utf-8)

1、截取GB2312字符用的函数 PHP代码 复制代码 代码如下: <?php //截取中文字符串 function mysubstr($str, $start, $len) {...

使用Huagepage和PGO来提升PHP7的执行性能

Hugepage PHP7刚刚发布了RC4, 包含一些bug修复和一个我们最新的性能提升成果, 那就是”HugePageFy PHP TEXT segment”, 通过启用这个特性,PH...

php实现的Cookies操作类实例

本文实例讲述了PHP实现的Cookies操作类及其用法,分享给大家供大家参考。具体分析如下: 一、功能: 1.保存,读取,更新,清除cookies数据。 2.可设置前缀。 3.强制超时控...

在数据量大(超过10万)的情况下

这个方法不错。 那你大可以把默认值设为99999...