- 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.
推薦閱讀
- JavaScript:Functional Programming for JavaScript Developers
- Vue.js快速入門與深入實戰(zhàn)
- 實用防銹油配方與制備200例
- PHP 編程從入門到實踐
- RISC-V體系結(jié)構(gòu)編程與實踐(第2版)
- Python之光:Python編程入門與實戰(zhàn)
- 精通Python自動化編程
- 持續(xù)集成與持續(xù)交付實戰(zhàn):用Jenkins、Travis CI和CircleCI構(gòu)建和發(fā)布大規(guī)模高質(zhì)量軟件
- Essential C++(中文版)
- Python編程:從入門到實踐(第3版)
- HTML+CSS+JavaScript編程入門指南(全2冊)
- 單片機(jī)原理及應(yīng)用技術(shù)
- Python商務(wù)數(shù)據(jù)分析(微課版)
- Java并發(fā)實現(xiàn)原理:JDK源碼剖析
- Offer來了:Java面試核心知識點精講(框架篇)