dpfln86244 2015-01-12 20:51
浏览 70
已采纳

Codeigniter - 扩展我自己的控制器

I'd like to know if it's possible to extend my own controllers. I've been working on web-based applications for a while and I'm now starting to find each customer that wishes to use the application has different requirements of how it should work. My thoughts are that if I generate a base structure and then extend the controllers to override any of the functions that the customers require to work differently.

First of all, could you tell me if I'm on the correct track, and secondly, how do I go about extending my own controllers (if I can)? I've tried the usual:

Class Reports2 extends Reports { }

This doesn't work but I'm guessing it has something to do with the location of the file I'm trying to extend. My file structure is as follows:

Application
--->controllers
-------->control_panel
------------>reports.php
  • 写回答

1条回答 默认 最新

  • drozwmi5440 2015-01-12 21:07
    关注

    If I am not mistaken then you should be able to easily do this:

    reports2.php

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    require_once(APPPATH.'controllers/control_panel/reports.php');
    
    Class Reports2 extends Reports {
    
        public function __construct(){
            parent::_construct();
        }
    
        public function index(){
    
        }
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集