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
- 1. Codeigniter get single row
- 2. Codeigniter Redirect HTTP Urls to HTTPS
- 3. Codeigniter Inner Join With Multiple Tables
- 4. Codeigniter Search Comma-separated values in MySql