ThinkCMF5.0.18报Object of class think\Request could not be converted to string错误解决办法

作者:星辰网络工作室 日期:2019-09-26 浏览:335

QQ截图20190926170112.jpg

[4096] ErrorException in Loader.php line 526

Object of class think\Request could not be converted to string

  public static function parseName($name, $type = 0, $ucfirst = true)
    {
        if ($type) {
            $name = preg_replace_callback('/_([a-zA-Z])/', function ($match) {
                return strtoupper($match[1]);
            }, $name);
            return $ucfirst ? ucfirst($name) : lcfirst($name);
        }

        return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_"));
    }

  找到/home/wwwroot/default/test/simplewind/thinkphp/library/think/view/driver/Think.php line 132

  把$template = str_replace('.', DS, $controller) . $depr . (1 == $this->config['auto_rule'] ? Loader::parseName($request->action(true)) : $request->action());

  修改成$template = str_replace('.', DS, $controller) . $depr . $request->action();

这样就能不报错了

THINKCMF_VERSION

5.0.180901

THINK_VERSION

5.0.20