CodeIgniter:如何获取Controller、Action、URL信息 [英] CodeIgniter: How to get Controller, Action, URL information
本文介绍了CodeIgniter:如何获取Controller、Action、URL信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些网址:
如何从这些 URL 中获取控制器名称、操作名称.我是 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();
这篇关于CodeIgniter:如何获取Controller、Action、URL信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文