开发者

How to access function from every controller in codeigniter

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['u开发者_JAVA百科rl']);
}


There are a few possibilities:

  • 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.


One solution would be to create your own library.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜