官术网_书友最值得收藏!

Creating the MY_Controller file

All projects in this book make use of the MY_Controller file; this is the same for all projects.

Create the MY_Controller.php file at /path/to/codeigniter/application/core/ and add the following code to it:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Controller extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->helper('security');
        $this->load->helper('language');

        // Load language file
        $this->lang->load('en_admin', 'english');
    }
}

As you can see, we load helpers that are common to all projects, such as the form helper and the language helper, among others. The language file is also loaded here.

All the controllers in the project extend from this MY_Controller file rather than the default CI_Controller file.

主站蜘蛛池模板: 文山县| 进贤县| 白河县| 喀喇| 稻城县| 慈利县| 呼伦贝尔市| 林州市| 梁河县| 安化县| 双峰县| 临泽县| 福贡县| 东明县| 新建县| 甘泉县| 湟中县| 丘北县| 安康市| 汶川县| 呼和浩特市| 阿拉善盟| 上杭县| 白银市| 香港 | 明溪县| 汪清县| 泗阳县| 德州市| 甘泉县| 长丰县| 和龙市| 宾川县| 左权县| 宝鸡市| 休宁县| 抚州市| 环江| 桐梓县| 土默特右旗| 谢通门县|