CI官方解釋:php
加載器,顧名思義,是用於加載元素的,加載的元素能夠是庫(類),視圖文件 , 驅動器 ,輔助函數 , 模型 或其餘你本身的文件。html
在開發過程當中,通常都會繼承框架Controller文件,該文件位置爲system\core\Controller.php。數據庫
在該文件的__construct方法:bootstrap
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'); }
$this->load =& load_class('Loader', 'core');框架
代表在文件運行的時候會自動加載Loader類,因此能夠直接在自定義控制器中使用 $this->load的相關方法。ide
Loader類分裝瞭如下方法:函數
library() ====》加載lib文件 model() ====》加載model文件 database() ====》加載db文件 dbutil() =====》官方解釋,感受是除了加載默認數據庫外的其餘數據庫 dbforge() ====》加載Db文件,可用於操做表結構 view() =====》加載view文件 file() =====》加載文件 helper() =====》該方法用於加載輔助函數文件,其中 file_name 爲加載的文件名,不帶 _helper.php 後綴。 helpers() =====》An alias for the helper() method in case the developer has written the plural form of it.該方法的註釋內容,防止開發人員建立複數形式 language() ======》加載語言包文件 config() ======》加載配置文件,除了在config/autoload.php中加載過的文件 driver() ======》加載驅動文件