Php CI_控制器中的加载方法在哪里
在system/core/Controller.php中,我看到了以下代码:Php CI_控制器中的加载方法在哪里,php,codeigniter,Php,Codeigniter,在system/core/Controller.php中,我看到了以下代码: public function __construct() { self::$instance =& $this; // Assign all the class objects that were instantiated by the // bootstrap file (CodeIgniter.php) to local class variables // so tha
public function __construct()
{
self::$instance =& $this;
// Assign all the class objects that were instantiated by the
// bootstrap file (CodeIgniter.php) to local class variables
// so that CI can run as one big super object.
foreach (is_loaded() as $var => $class)
{
$this->$var =& load_class($class);
}
$this->load =& load_class('Loader', 'core');
$this->load->initialize();
log_message('info', 'Controller Class Initialized');
}
我尝试了很多次来寻找load方法,load_class()
它们在哪里?函数
load_class()
在system/core/common.php
中定义,该函数包含在index.php
的最后一行中
require_once BASEPATH.'core/CodeIgniter.php';
CodeIgniter.php
引导整个框架
因此,当控制器构造函数运行函数load\u class()
时,已定义并准备好开始工作
load\u class()
正在创建加载器类的实例供控制器使用。Loader有很多方法。最常见的用途是加载其他框架库、模型、帮助程序和视图。
比如说
$this->load->library('form_validation');
$this->load->model('your_favorite_model');
$this->load->helper('url');
$this->load->view('welcome_view');
转到
/system/core/Loader.php
并搜索公共函数视图(
)、公共函数库(
)、公共函数模型(
)等。我不清楚。我仍然找不到答案。如果没有include、require file或extensed类,我如何调用它?我不清楚什么是“It”是。您想调用什么?正如您在CI_控制器类中看到的,没有require file或extends类。如何在CI_控制器中使用“load_class()”?
$this->load->library('form_validation');
$this->load->model('your_favorite_model');
$this->load->helper('url');
$this->load->view('welcome_view');