Skip to content

Instantly share code, notes, and snippets.

@og-shawn-crigger
Created April 7, 2012 06:41
Show Gist options
  • Save og-shawn-crigger/2325988 to your computer and use it in GitHub Desktop.
Save og-shawn-crigger/2325988 to your computer and use it in GitHub Desktop.
CodeIgniter Snippets - How to get Controller, Method and Module name - Router | URI Classes

CodeIgniter - Working with URL Params

Target a Specific Value

$this->uri->segment(n); // n=1 for controller, n=2 for method, etc

Using the Router Class

//-------------------------------------
//! Get Controller Name 
//-------------------------------------	
$this->router->fetch_class();

//-------------------------------------
//! Get Method Name 
//-------------------------------------	
$this->router->fetch_method();

//-------------------------------------
//! Get Module Name in HMVC
//-------------------------------------	
$this->router->fetch_module();
Copy link

ghost commented May 4, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment