0

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

是什么$this->load->view意思?$thisCI_Controller类。load和怎么样view

4

2 回答 2

1

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
于 2013-07-04T02:57:39.577 回答
1

$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.

于 2013-07-04T03:00:31.830 回答