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 : https://arjunphp.com/cat/article/id/123
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
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.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.