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

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.

主站蜘蛛池模板: 毕节市| 芮城县| 溧水县| 石首市| 喀喇沁旗| 紫阳县| 西华县| 万全县| 隆昌县| 西乌| 巢湖市| 伊宁县| 外汇| 蚌埠市| 清涧县| 广丰县| 垫江县| 和平县| 日土县| 沙湾县| 鲁甸县| 彭州市| 府谷县| 安乡县| 万安县| 虎林市| 富裕县| 罗平县| 施秉县| 灵宝市| 新泰市| 山阴县| 印江| 长顺县| 寿宁县| 澄城县| 宜州市| 丰原市| 祁门县| 隆安县| 寻乌县|