登录

继承Controller类之后报错

<?php

namespace app\admins\controller;

use think\Controller;

use Util\data\Sysdb;

class Test extends Controller

{

public function index(){

$this->db = new Sysdb;

$res = $this->db->table('admins')->field('id,username')->lists();

dump($res);

}

}

会显示该网页无法运作,去掉extends Controller就不会报这个错

# PHP
22 22 941 天前 1351 次浏览

全部回复(5) 我要回复

  • autoload

    autoload2021-09-02 16:35:55

    你是tp6还是5,tp6继承BaseController

    回复
    0
  • 22

    tp5,我找到原因了,没有从入口文件访问

    22 · 2021-09-02 16:36:40
  • 22

    222021-08-31 09:27:19

    截屏2021-08-31 09.25.41.png报的这个错,而且我已经把调试模式打开了

    截屏2021-08-31 09.26.25.png

    回复
    0
  • autoload

    autoload2021-08-31 09:19:24

    会报什么错?截图来看看啊

    回复
    0
  • 22

    我发在下面了 您看看

    22 · 2021-08-31 09:27:35
  • 取消 回复 发送