Skip to content

Instantly share code, notes, and snippets.

@QETHAN
Created August 31, 2014 08:03
Show Gist options
  • Save QETHAN/2ee4879521c58ae4e7cf to your computer and use it in GitHub Desktop.
Save QETHAN/2ee4879521c58ae4e7cf to your computer and use it in GitHub Desktop.
php捕获异常信息
<?php
try {
throw new Exception('wrong');
} catch(Exception $ex) {
$msg = 'Error:'.$ex->getMessage()."\n";
$msg.= $ex->getTraceAsString()."\n";
$msg.= '异常行号:'.$ex->getLine()."\n";
$msg.= '所在文件:'.$ex->getFile()."\n";
//将异常信息记录到日志中
file_put_contents('error.log', $msg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment