Php – CodeIgniter: How to get Controller, Action, URL information

codeignitercodeigniter-2PHP

I have these URLs:

How to get controller name, action name from these URLs. I'm CodeIgniter newbie. Are there any helper function to get this info

Ex:

$params = helper_function( current_url() )

Where $params becomes something like

array (
  'controller' => 'system/settings', 
  'action' => 'edit', 
  '...'=>'...'
)

Best Answer

You could use the URI Class:

$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();
Related Topic