SG_*_*SG_ 5 php model-view-controller codeigniter hmvc
我想从另一个控制器(比如controller_b)调用控制器中的一个函数(比如controller_a)
请帮我 ..
共享控制器函数通常应该在扩展控制器类中:
<?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
}
}
Run Code Online (Sandbox Code Playgroud)
然后,确保需要使用此功能的任何控制器都扩展MY_Controller.