Codeigniter 获取对CodeIgnitor 4中null的成员函数view()的调用

Codeigniter 获取对CodeIgnitor 4中null的成员函数view()的调用,codeigniter,view,Codeigniter,View,如果我试图调用查看其显示在下方的错误,则我的控制器中的问题代码点火器4。下面给出了我的代码和错误 namespace App\Controllers; class Security extends BaseController{ /** * An array of helpers to be loaded automatically upon * class instantiation. These helpers will be available * to all other con

如果我试图调用查看其显示在下方的错误,则我的控制器中的问题代码点火器4。下面给出了我的代码和错误

namespace App\Controllers;

class Security extends BaseController{
/**
 * An array of helpers to be loaded automatically upon
 * class instantiation. These helpers will be available
 * to all other controllers that extend BaseController.
 *
 * @var array
 */
protected $helpers = ['curl'];

public function index(){
    $this->load->view('head');
    $this->load->view('security/login');
}



}
我面临的问题如下

CRITICAL - 2020-08-31 07:39:19 --> Call to a member function view() on null
#0/var/www/html/codeignitetor/system/CodeIgniter.php(918):App\Controllers\Security->index() #1/var/www/html/codeignitetor/system/CodeIgniter.php(404):CodeIgniter\CodeIgniter->runController() #2/var/www/html/codeignitetor/system/CodeIgniter.php(312):CodeIgniter\CodeIgniter->handleRequest() #3/var/www/html/codeignitetor/public/index.php(45):CodeIgniter\CodeIgniter->run() #4/var/www/html/codeignitor/system/Commands/Server/rewrite.php(34):require_once('/var/www/html/c…)
#5{main}

load
为空,因为在CI4中加载视图的方式不是这样的。如果您使用的是CI4版本,则需要确保您正在查看文档的CI4版本:

在CI4中,视图是通过调用
view()
加载的


您在代码中呈现的方式是如何在CI3中加载视图。3和4之间有实质性的变化,因此如果这是您第一次跳转,您应该全面查看文档。

是的,我得到了它,它是我的mistke CI4不是稳定版本,它的文档尚未更新
namespace App\Controllers;

class Security extends BaseController{
/**
 * An array of helpers to be loaded automatically upon
 * class instantiation. These helpers will be available
 * to all other controllers that extend BaseController.
 *
 * @var array
 */
protected $helpers = ['curl'];

public function index(){
    //$this->load->view('head');
    //$this->load->view('security/login');
    echo view('head');
    echo view('security/login');
}
}