当我调用$this->;时,在哪里可以找到函数视图;负载->;CodeIgniter中的视图


Where can I find the function view when I call $this->load->view in CodeIgniter?

当我扩展类CI_Controller并使用$this->load->view,并尝试打开controller.php时,我找不到view函数。

$this->load->view是什么意思?$this是指CI_Controller类。loadview怎么样?

$this->load->view将加载该视图。例如$this->load->view(ABC.php),它会在codeigniter的view文件夹中搜索ABC.php并加载它。这一行通常是控制器的最后一行。

关于CI_Controller是父控制器类,因此它可以继承其所有功能。

因此,如果你的url是example/abc/demo/,CodeIgniter会尝试找到一个名为demo.php的控制器,并加载它的视图,该视图将位于最后一行。

希望这会有所帮助。

load是一个带有CI_Loader实例的paroperty。CI_Loader::view是一种加载视图的方法:

view( string $view, array $vars = array(), boolean $return = FALSE )
Load View
This function is used to load a "view" file. It has three parameters:
    The name of the "view" file to be included.
    An associative array of data to be extracted for use in the view.
    TRUE/FALSE - whether to return the data or load it. In
some cases it's advantageous to be able to return data so that a developer can process it in some way.
Parameters
$view
$vars
$return