因为要写一个系统,所以又重新下载了thinkphp,然后安装了一下。回忆起这个问题很容易让新手朋友费解。会出现如下报错:Call to undefined method app\index\controller\Index::fetch()
其实就是没找到fetch属性,其实默认是有这个属性的。只是你没有使用罢了。
需要先使用Controller然后继承。 如下所示:
<?php
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{
public function index()
{
return $this->fetch();
}
}
本文详细解释了在ThinkPHP中遇到fetch()方法未定义的问题及其解决方案。通过正确继承Controller类并使用fetch()方法,新手可以避免此常见错误。
1024

被折叠的 条评论
为什么被折叠?



