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

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.

主站蜘蛛池模板: 金秀| 沙湾县| 乌鲁木齐县| 黄浦区| 岳西县| 胶南市| 农安县| 岢岚县| 龙里县| 信丰县| 高阳县| 岚皋县| 利辛县| 察哈| 简阳市| 五常市| 罗田县| 房产| 营山县| 镇赉县| 拉萨市| 安达市| 陆河县| 志丹县| 玉门市| 呼伦贝尔市| 绵阳市| 科技| 合川市| 邢台市| 福鼎市| 上杭县| 南通市| 宝山区| 神池县| 香港 | 浦东新区| 应城市| 临武县| 仙桃市| 太和县|