用PHP即?捕捉PHP原始?中的??并?送email通知
??PHP的朋友都知道,其?最?心的就是程序中出?一些?常或??,?些??如果?出到用?的?幕?把用????,甚至?此?了工作,如果不?出到?幕就得想?法??到日?中,但是似乎不是每?人都有查看??日?的??,?了解????尬的??,所以我?了?段代?,其用意就是?我??的php程式出?的?候把???容捕捉出?然後?到我?的email?.
先看效果:
Define('SYS_DEBUG',false);IF(SYS_DEBUG) {ini_set('display_errors','on');Error_reporting(E_ALL);//上?后使用??定Error_reporting(E_ERROR | E_WARNING | E_PARSE);}Else{ini_set('display_errors','off');Error_reporting(0);}//??捕捉Register_shutdown_function('Fun::Error');Class Fun{/**通用出??理参数:要?出的?容,是否?止?行程序?明:有?值??函式可以用??出自定?的???容另外?可以配合Register_shutdown_function??自?抓取???容,??抓取的???容?送到Email?Register_shutdown_function的?制是程序?行完?或中途出???用函?如果是自?抓取???被?用,??取得最後一次出?的?容,如果???有???容?跳出返回:?容?被直接?出至?幕或Email?用法:Fun::Error('???容');Fun::Error('???容',False);/**/Public Static Function Error($M='',$E=True){$ErrTpl='<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body><table cellspacing="0" cellpadding="0" border="0"><tr><td style="padding:5px;background-color:#F57900;font-size:13px;border:1px solid #444;color:#222;">{$M}</td></tr></table>';$M=Trim($M);IF($M!='') {//手工?用$M=' <b>注意:</b> '.$M;Echo Strtr($ErrTpl,Array('{$M}'=>$M));unSet($ErrTpl);IF($E===True) {Die();}Return ;}Else{//程式?行完?自?抓取????用$M=error_get_last();//取得最後?生的??IF(!Is_array($M) Or Count($M)<4) {Unset($M);Return ;}IF(!File_Exists($M['file'])) {Unset($M);Return ;}//取得5行出???代?,如果取不到?容,?明出??案不存在$E=Array_slice(File($M['file']),($M['line']-4),5);IF(!Is_array($E)) {Unset($M,$E);Return ;}$E['M']='';For($i=0;$i<5;$i++) {$E[$i]=isSet($E[$i]) ? $E[$i] : '';$E['M'].=' ';$E['M'].=($i==3) ? '<b>'.(($M['line']-3)+($i+1)).'</b>' : (($M['line']-3)+($i+1));$E['M'].=': '.Htmlspecialchars($E[$i],ENT_QUOTES,'UTF-8').'<br>';}$E=&$E['M'];$M='<b>自?捕捉到有???生!</b><br><br><b>??描述:</b><br> <b>'.$M['file'].'</b>的第<b>'.$M['line'].'</b>行出?了?型?<b>'.$M['type'].'</b>的??:<br> '.$M['message'].'<br><br><b>??代?:</b><br>'.$E.'<br>'.self::now('Y-m-d H:i:s',time()).'<br>';$M=Strtr($ErrTpl,Array('{$M}'=>$M));unSet($ErrTpl);$G=seft::getG('SYS','config');IF(!self::Mail2($G['Spe'],'警告: '.$G['Tit'].' 出? PHP 程式??!',$M) And SYS_DEBUG===True){throw new Exception('警告: '.$G['Tit'].' 出? PHP 程式??!<br><br>'.$M);}IF(SYS_DEBUG) {Echo $M;}unSet($E,$M,$G);Die();}}/**发送??参数:收件人,?件??(不可有?行符),?件?容(行?行之?必?用\n分隔,每行不可超?70?字符)?明:?用PHP?置函式Mail?送??返回:返回布?值用法:$IsSend=Fun::Mail2($email,$tit,$msg);/**/Public Static Function Mail2($to,$tit,$msg) {IF(Filter_var($to,FILTER_VALIDATE_EMAIL)==''){throw new Exception('??地址??!');}$tit='=?UTF-8?B?'.Base64_Encode($tit).'?=';$msg = str_replace("\n.","\n..",$msg); //Windows如果在一行开头发现一个句号则会被删掉,要避免此问题将单个句号替换成两个句号Return Mail($to,$tit,$msg,'From:'.seft::getG('config/SYS/Mal')."\n".'Content-Type:text/html;charset=utf-8');}}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
