Question Detail

How to get url Segment in Codeigniter?

6 years ago Views 1841 Visit Post Reply

How can I get Url Segment from the URL in CodeIgniter I have tried many ways but not succeeded Please tell me the exact code how to get URI segment? 

Thread Reply

Bili Greed

- 6 years ago

This provides you to retrieve information from your URI strings

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

consider this example

it will return

$this->uri->segment(1); // controller
$this->uri->segment(2); // action
$this->uri->segment(3); // 1stsegment
$this->uri->segment(4); // 2ndsegment