php - Codeigniter中是否有 super Controller 或全局 Controller

标签 php model-view-controller codeigniter hmvc

我想从另一个 Controller (比如 controller_b)调用一个 Controller (比如 controller_a)中的函数

请帮帮我..

最佳答案

共享 Controller 函数通常应该在扩展 Controller 类中:

<?php
/**
 *  File: /application/core/MY_Controller.php
 */
class MY_Controller extends CI_Controller {

    /**
     * Prefix with an underscore if you don't want it
     * publicly available through URI-routing
     */
    public function _some_shared_method()
    {
        // some common operation here
    }

}

然后,确保任何需要使用此功能的 Controller 都扩展MY_Controller

关于php - Codeigniter中是否有 super Controller 或全局 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9652681/

相关文章:

php - 消息库、My_Controller 和 __remap 问题

objective-c - IOS View 改变

java - MVC 架构 EJB 功能

mysql - Codeigniter MySql 数据库连接问题

php - LEFT JOIN 未输出所需结果

javascript - 用其复选框包装一些输入并发送到数据库

php - 为什么多个场景在 Yii 中不起作用?

php - 在哪里散列密码(服务器 || 客户端)

c++ - QSpinBox 绘制不正确

php - 如何描述 codeigniter 中的通知、错误等全局消息?