Heim  >  Artikel  >  Backend-Entwicklung  >  CI中的load方法是从哪来的

CI中的load方法是从哪来的

WBOY
WBOYOriginal
2016-06-23 13:34:03910Durchsuche

看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   //视图。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn