CodeIgniter URI class

Work with URL string in CodeIgniter

$uri_param = $this->uri->segment(2); // get 2-nd uri segment; site.com/news/archive/777 - 2-nd segment will be 'archive'
$uri_param = $this->uri->segment(2,'default'); // get uri segment or return default value if it is empty
$this->uri->uri_string(); // site.com/news/archive/777 - will return 'news/archive/777'
$this->uri->total_segments(); // returns the total number of segments; site.com/news/archive/777 - will return '3'

Leave a Reply

Your email address will not be published. Required fields are marked *