我正在使用codeigniter&通过扩展Exception类
在php的帮助下显示全局异常现在问题是:在同一页面上异常消息(见屏幕截图)显示多次,具体取决于生成的异常数量...我想在浏览器中只向用户显示消息...
如何在浏览器中只显示一条消息?
生成异常消息的代码
function __construct() {
parent::__construct();
}
function log_exception($severity, $message, $filepath, $line) {
if (ENVIRONMENT === 'production') {
$to = "developer@example.com";
$subject = "Fitness Trainer -Production Exception";
$message = 'Severity: ' . $severity . ' --> ' . $message . ' ' . $filepath . '<br/> ' . $line;
$from = "robot@gmail.com";
$headers = "From:" . $from;
mail($to, $subject, $message, $headers);
echo '<div style="width: 70%;text-align: left;margin-left: 15%;" class="alert alert-warning text-center alert-dismissible server-side-msg text-capitalize" role="alert">
<span class="glyphicon glyphicon-warning-sign"></span>
<strong>We apologize for the inconvenience,An exception occurred from our side and will work to resolve it....
</strong>
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
</div>';
}
parent::log_exception($severity, $message, $filepath, $line);
}
}?>
重复消息的屏幕截图