Home  >  Article  >  Backend Development  >  CI中的load方法是从哪来的,该怎么解决

CI中的load方法是从哪来的,该怎么解决

WBOY
WBOYOriginal
2016-06-13 12:20:30938browse

CI中的load方法是从哪来的
看CI默认文件中有
public function index()
{
$this->load->view('welcome_message');
}
按说这个load是一个方法,但是查了一下没有呢,怪事啊!难道他是php自带的函数不成
------解决思路----------------------
显然不是,如果是PHP自带的函数,最起码应该是load(); 而不是$this->load->xxx
既然是$this->load,也就是说,load实际上是Controller的一个成员。
CI_controller初始化的时候(system/core/Controller.php):
$this->load =& load_class('Loader', 'core');
换句话说,load实际上是Loader的实例,它是ci的加载器,主要负责CI的类库的加载,例如:
$this->load->config    //配置
$this->load->model //模型
$this->load->view   //视图。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn