当我扩展类CI_Controller
并使用$this->load->view
,并尝试打开controller.php
时,我找不到该view
功能。
是什么$this->load->view
意思?$this
指CI_Controller
类。load
和怎么样view
?
当我扩展类CI_Controller
并使用$this->load->view
,并尝试打开controller.php
时,我找不到该view
功能。
是什么$this->load->view
意思?$this
指CI_Controller
类。load
和怎么样view
?
load
是一个具有CI_Loader
. 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
$this->load->view will load the view. For example $this->load->view(ABC.php) then it will search for ABC.php in view folder of codeigniter and load it. This line usually be the last line of your controller.
About CI_Controller is the parent controller class so that it can inherit all its functions.
So, if your url is example/abc/demo/ ,CodeIgniter would attempt to find a controller named demo.php and load its view which will be at the last line.
hope this will help.