如何获取Controller,Action,URL信息与CodeIgniter [英] How to get Controller, Action, URL informations with CodeIgniter
本文介绍了如何获取Controller,Action,URL信息与CodeIgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些网址:
- http://backend.domain.com/system/setting/edit/12
- http://backend.domain.com/product/edit/1
如何从这些网址获取控制器名称,操作名称。我是codeigniter新手。是否有帮助函数来获取此信息
How to get controller name, action name from these urls. I'm codeigniter newbie. Are there any helper function to get this info
例如:
$params = helper_function( current_url() )
其中 $ params
变成类似
array (
'controller' => 'system/settings',
'action' => 'edit',
'...'=>'...'
)
推荐答案
您可以使用 URI类:
$this->uri->segment(n); // n=1 for controller, n=2 for method, etc
以下工作,但目前无法测试:
I've also been told that the following work, but am currently unable to test:
$this->router->fetch_class();
$this->router->fetch_method();
这篇关于如何获取Controller,Action,URL信息与CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文