- CodeIgniter Web Application Blueprints
- Rob Foster
- 95字
- 2021-08-06 19:34:28
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.
推薦閱讀
- OpenStack Cloud Computing Cookbook(Third Edition)
- Facebook Application Development with Graph API Cookbook
- 軟件項目估算
- Getting Started with React
- HTML5+CSS3網(wǎng)站設(shè)計基礎(chǔ)教程
- Python貝葉斯分析(第2版)
- SQL基礎(chǔ)教程(第2版)
- Buildbox 2.x Game Development
- Beginning C++ Game Programming
- OpenCV 3計算機視覺:Python語言實現(xiàn)(原書第2版)
- Mastering Apache Camel
- 信息學奧林匹克競賽初賽精講精練
- Android項目實戰(zhàn):博學谷
- Apache Kafka 1.0 Cookbook
- 數(shù)據(jù)庫技術(shù)及應(yīng)用教程上機指導與習題(第2版)