您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

分享一个php 的异常处理程序_PHP教程

2024/3/24 5:54:27发布22次查看
直接上代码
'.[shutdown] lvl: . $lasterror['type'] . | msg: . $lasterror['message'] . | file: . $lasterror['file'] . | ln: . $lasterror['line'].\n;file_put_contents('./log/'.date(ymd).'shutdownlog.txt',$error,file_append);//友好提示用户ob_end_clean();die('对不起,我出错了!');}}register_shutdown_function('shutdownhandler');}if(!defined('debug')){ function errorhandler($errno, $errstr = '', $errfile = '', $errline = 0){//写日志$exception = new \errorexception($errstr, 0, $errno, $errfile, $errline);$msg = strval(date(y-m-d h:i:s)).'=>'.'type:'.geterrtypename($errno).' '.getmsg($exception);file_put_contents('./log/'.date(ymd).'error.txt',$msg,file_append);switch ($errno){case e_notice:return ;case e_deprecated:return;}throw $exception;}function geterrtypename($errno){switch ($errno){case e_notice:return 'e_notice' ;case e_deprecated:return 'e_deprecated';default:return $errno;}}function exceptionhandler($ex){$msg = strval(date(y-m-d h:i:s)).'=>'.getmsg($ex);file_put_contents('./log/'.date(ymd).'exception.txt',$msg,file_append);}function getmsg($exception){//获取最准确的异常 while($exception->getprevious())$exception = $exception->getprevious();$msg = ' message: '.$exception->getmessage();$msg .= ' file: '.$exception->getfile().':'.$exception->getline().\n;return $msg;}set_error_handler('errorhandler',e_all);set_exception_handler('exceptionhandler');}?>
http://www.bkjia.com/phpjc/825533.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/825533.htmltecharticle直接上代码 php//exceptionhandle.php xiecongwen 20140620//define('debug',true);/*** display all errors when application_env is development.*/if (defined('debug')) {error_report...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product