Class Exceptions extends Exception
{
/**
* 异常日志存储文件夹
* @public string
*/
//public $_Dir = '';
public $_Dir = LOG_DIR;
/**
* 异常日志文件命名规则
* @public string
* 可设置包含date函数的动态名字,如 'Exception_'.date('m-d').'.log'
*/
//public $_Filename = 'Error.log';
public $_Filename = LOG_FILENAME;
public function __construct($_Message=0, $_Code=0)
{
parent::__construct($_Message, $_Code);
}
public function __toString()
{
return date('[m-d-Y H:i:s]')." [{$this->code}] {$this->message} IN {$this->file} on LINE {$this->line} - {$_SERVER['REQUEST_URI']}";
}
public function Log()
{
error_log($this->__toString()."\r\n", 3, $this->_Dir.$this->_Filename);
return $this;
}
public function View()
{
$_Code= "<html>\n<head>\n<title>错误</title>\n</head>\n<body>\n<div style='color:#ea0000;font-size:22px;font-weight:bold;'>%s 错误</div>\n".
"<hr><div style='color:#666;font-size:16px;background:#f6f6f6;padding:8px;line-height:25px'>\n".
"在访问 %s 时发生错误,错误信息如下:\n".
"<div style='font-size:14px;'>\n<li>文件: %s<br>\n<li>行数: %s<br>\n<li>错误代码: %1\$s<br>\n<li>错误信息: %s<br>\n".
"<li>发生时间: %s<br>\n</div>\n</div>\n</body>\n</html>";
echo sprintf($_Code, $this->code, $_SERVER['REQUEST_URI'], $this->file, $this->line, $this->message, date('Y-m-d H:i:s'));
return $this;
}
}
分享到:
相关推荐
throw new Exception( sprintf( 'Could not find file \'%s\'. It is generated by Composer. Use \'install --prefer-source\' or \'update --prefer-source\' Composer commands to ...
php class Exception { protected $message = ‘Unknown exception’; // 异常信息 protected $code = 0; // 用户自定义异常代码 protected $file; // 发生异常的文件名 protected $line; // 发生异常的代码行号 ...
error与exception的区别查阅网上资料大多是java的解释,貌似php的异常处理过程与java差不多 java中的Object继承结构如下: Object—->Throwable——–> Exception —-> RuntimeException | Error Error都是unchecked...
说完 Logic/Runtime Exception 的区别,我们在看看其他 SPL 提供的 Exception 的意义:Bad(Method/Function
极好的 PHP的更好的例外Exceptional旨在提供一种从根本上增强的Exception框架,该框架将Exception的含义与基础实现功能分离开来。异常异常可用于极大地简化代码中生成和引发错误的方式,尤其是在编写共享库时。将...
PHP发送邮件失败解决方案,PHP发送邮件不成功解决办法,请下载压缩包中的代码,按照说明文档操作即可解决发送邮件问题
vim /etc/php/php.ini 找到下面这一行并将前面的分号注释去掉,保存退出。 ; extension=mysqli 二、第二个问题 1、问题描述 提示 mysqli::__construct(): (HY000/2002) 类似的信息 2、我的解决方案 开启mysql服务 ...
php代码-exception测试
目前的压缩包名为:... WxPay.Exception.php"异常类" WxPay.Notify.php"回调函数的父类" 6. logs-这个主要用来存放在支付过程中生成的各种日志文件 接下来我们进行文件配置 具体操作看文件里面的Word文档
在PHP中调用IE使用如下代码: 复制代码 代码如下: browser = new COM(“InternetExplorer.Application”); 无法正常调用,直接报错: 复制代码 代码如下: Fatal error: Uncaught exception ‘com_exception’ with ...
use Whoops\Exception\ErrorException; use Whoops\Exception\Inspector; use Whoops\Handler\CallbackHandler; use Whoops\Handler\Handler; use Whoops\Handler\HandlerInterface; use Whoops\Util\...
7 Error and Exception Handling Part II: Using MySQL 8 Designing Your Web Database 9 Creating Your Web Database 10 Working with Your MySQL Database 11 Accessing Your MySQL Database from the Web with ...
异常(Exception)用于在指定的错误发生时改变脚本的正常流程。 什么是异常? PHP 5 提供了一种新的面向对象的错误处理方法。 异常处理用于在指定的错误(异常)情况发生时改变脚本的正常流程。这种情况称为异常。 当...
class Exception extends \Exception { }Hash,一般翻译做“散列”,也有直接音译为“哈希”的,就是把任意长度的输入(又叫做预映射, pre-image),通过散列算法,变换成固定长度的输出,该输出就是散列值。...
Chapter 7 Error and Exception Handling Part II: Using MySQL Chapter 8 Designing Your Web Database Chapter 9 Creating Your Web Database Chapter 10 Working with Your MySQL Database Chapter 11 Accessing...
Kubernetes开发环境 ...git clone git @github .com :French - Exception - 2 / vagranti - dev.php.git " vagranti-dev.php_i ${instance} " set-location " vagranti-dev.php_i ${instance} " 配置中