tp5错误日志输出:[ error ] [2]Declaration of app\Api::error($info) should be compatible with think\Controller::error($msg = '', $url = NULL, $data = '', $wait = 3, array $header = Array)

时间:2021-08-10 21:33:20

在调试页面时,报错:

[ error ] [2]Declaration of app\Api::error($info) should be compatible with think\Controller::error($msg = '', $url = NULL, $data = '', $wait = 3, array $header = Array)

image.png

错误原因:

使用了tp中禁用的关键词作为方法名了,如此处的,error。将其改为error2或其它名称即可解决。

public function error2($info) {

        // 返回错误

        $attr = input();

        $json = $this->info(false);

        if (isset($info)) $json['info'] = $info;

        return json($json);

    }

同时引用的地方也要改过来

 return $this->error2('参数错误');

猜你喜欢

版权所有:2019-2021 无双建设   网站地图