Codeigniter get Controller Name from URL


Get Controller Name from URL We can use router to get the current controller name in codiegniter. Here in this article, we are going to explain how you can use $router to get the current controller and method name.


Codeigniter get Controller Name from URL Example

You can get the controller name and method name of current URL simply as below –

Example:

$this->router->class; // will give controller class
$this->router->method; // will return method name

For older version of codeigniter use the following syntax-

$this->router->fetch_class();
$this->router->fetch_method();

Advertisements

Add Comment

📖 Read More