drgaeqdqiiyg14608 2013-03-17 18:27
浏览 38
已采纳

如何为codeigniter中的所有子控制器组织主控制器

I want to make something like this:

Main_Controller -> {


   child1_controller

   child2_controller

   child3_controller


}

the purpose is to execute the constructor of the Main class everytime the child classes have been executed, it looks like some kind of multi extending, for example if i want to check in the main constructor wheter is admin or not, but the problem is when i do that

child1_controller extends Main_Controller

i get an error Class 'Main_Controller' not found

  • 写回答

1条回答 默认 最新

  • doukun0888 2013-03-17 18:31
    关注

    Use the built in core class extending mechanism, if you name your base controller class appropriately (with the default prefix MY_) and put it under application/core CI should pick it up.

    Once you got your MY_Controller set up, you can make your child controllers under application/controllers/ extend that, and call for parent::__construct() in their __construct.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事: