万维当云伯乐 CDN华纳云
ThinkPHP2024-11-22966 阅读

thinkphp6、thinkphp8 自定义异常显示页面

本文摘要进入 config/app.php 里面,增加下面的信息 // 异常页面的模板文件 'exception_tmpl' => app()->isDebug()==true ? app()->getThinkPath() . 'tpl/think_exception.tpl' : \think\facade\App::ge
丽萨主机
AD:
【广告招商】文章正文文字广告位开放合作
进入 config/app.php 里面,增加下面的信息
 // 异常页面的模板文件
    'exception_tmpl'   => app()->isDebug()==true ?
                          app()->getThinkPath() . 'tpl/think_exception.tpl' :
                          \think\facade\App::getAppPath() . 'error.html',
    
    'http_exception_template' => [
        // 定义404错误的模板文件地址
        404 => \think\facade\App::getAppPath() . '404.html',
        // 还可以定义其它的HTTP status
        500 => \think\facade\App::getAppPath() . '500.html',
    ],
  我本人的代码是:
 // 异常页面的模板文件
    'exception_tmpl' => app()->getThinkPath() . 'tpl/think_exception.tpl',

    //指定404页面
    'http_exception_template' => [
        404 => app()->getRootPath() . '/view/index/404.html', // 指定404错误的模板文件
        // 可以继续添加其他HTTP状态码和模板
    ],
 
广告招商文章内容详情页下 · 优质席位开放中合作咨询