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

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.

主站蜘蛛池模板: 凉城县| 翼城县| 彝良县| 建平县| 和平区| 贵定县| 海口市| 章丘市| 崇礼县| 南木林县| 雷州市| 建宁县| 玉树县| 独山县| 绥棱县| 阿瓦提县| 开远市| 柳河县| 鄢陵县| 收藏| 钦州市| 麻阳| 上饶市| 塘沽区| 鄂尔多斯市| 凌海市| 通城县| 山丹县| 温泉县| 溧水县| 襄城县| 汉寿县| 师宗县| 滨海县| 宁德市| 三门峡市| 砚山县| 项城市| 始兴县| 昭平县| 潍坊市|