我想从另一个 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/