CodeIgniter URI class

Work with URL string in CodeIgniter

$uri_param = $this->uri->segment(2); // get 2-nd uri segment; - 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(); // - will return 'news/archive/777'
$this->uri->total_segments(); // returns the total number of segments; - will return '3'

Leave a Reply

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