Thinkphp5.0之异常处理

1.默认异常处理
在调试模式下,系统默认展现的错误页面:
请输入图片描述php

异常处理接管app

1.修改config.phpurl

'app_debug' => false,
2.在配置文件里添加以下代码spa

// 异常处理handle类 留空使用 \think\exception\Handle
'exception_handle' => '\\app\\common\\exception\\Http',
3.添加错误异常模块代码:debug

<?php
namespace appcommonexception;
use thinkexceptionHandle;
class Http extends Handle
{调试

public function render(\Exception $e){
if(config('app_debug')){
//若是开启debug则正常报错
return parent::render($e);
}else{
//重定向页面
header("Location:".url('index/index/index'));
}
}
}图片

加完这些东西,就不会出现那些烦人的报错代码啦!io

相关文章
相关标签/搜索