Created
August 31, 2014 08:03
-
-
Save QETHAN/2ee4879521c58ae4e7cf to your computer and use it in GitHub Desktop.
php捕获异常信息
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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