- 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.
推薦閱讀
- Beginning C++ Game Programming
- 程序員面試筆試寶典
- 架構(gòu)不再難(全5冊(cè))
- JMeter 性能測(cè)試實(shí)戰(zhàn)(第2版)
- PHP+MySQL網(wǎng)站開發(fā)技術(shù)項(xiàng)目式教程(第2版)
- Production Ready OpenStack:Recipes for Successful Environments
- 機(jī)械工程師Python編程:入門、實(shí)戰(zhàn)與進(jìn)階
- Python Data Analysis(Second Edition)
- 人人都是網(wǎng)站分析師:從分析師的視角理解網(wǎng)站和解讀數(shù)據(jù)
- ADI DSP應(yīng)用技術(shù)集錦
- 程序員修煉之道:通向務(wù)實(shí)的最高境界(第2版)
- Scala編程實(shí)戰(zhàn)(原書第2版)
- 從Java到Web程序設(shè)計(jì)教程
- Beginning C++ Game Programming
- Mastering Elixir