如何访问codeigniter中每个控制器的功能 [英] How to access function from every controller in codeigniter

查看:111
本文介绍了如何访问codeigniter中每个控制器的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友您在一个控制器中拥有此功能,我如何从其他控制器访问它?ps help

Hi friends hi have this function in one controller , how can i access it from every other controller ?pls help

public function click_add($ads_id){
    //some statement here
    redirect($ads_site['url']);
}


推荐答案

  • Define a helper
  • Create a parent controller class from which all other controllers in your application extend
  • Create a library
  • Use ModularExtensions to allow calling one controller inside another

这取决于函数应该做什么。如果它不应该访问模型,那么你可以去前三个选项。否则,我会建议后两个。

It all depends on what exactly the function should do. If it shouldn't access the model, then you could go for the first three options. Otherwise I'd suggest the latter two.

这篇关于如何访问codeigniter中每个控制器的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆