CodeIgniter URI Segments ?

This post is about codeigniter URI Segments, ci’s uri class is initialized automatically by the system. with the help of uri segments we an get values from the URL , just like GET[‘key’] method in core php here in codeigniter the key may be numbe or string(when you get uri segment as an associative array). the more usefully thing is we can get re-routed segments information also.

How to access uri segments

we can call uri’s class method segment(), any were to access uri segments, this method accepts two parameters, one is segment number and second parameter is default value and second parameter is optional.

For example if the URL is :

cat is the 1st segment, article is the 2nd segment, id is the 3rd segment and 123 is the fourth segment . You can access each segment using $this->uri->segment(n)

to know more methods of uri class please visit ci official document.

I hope this tutorial helps you please don’t forget to give us your feedback in comments.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
Joshua Ifeanyichukwu Oguchi II
Joshua Ifeanyichukwu Oguchi II
3 years ago

This is so helpful. Thanks so much Protection Status
Would love your thoughts, please comment.x