
Uri segment not working in codeigniter
Uri segment not working in codeigniter
In this session, we’ll try our hand at solving the "Uri segment not working in codeigniter" puzzle by using the computer language.
Here we have an URI (http://example.com /category/codeigniter/20
) and we have to get the last segment of URI which value is 20.
So we can get the last (which is at number 3) segment of URI using $this->uri->segment(3)
. Here we have three segments in this URL like category is at place 1, codeigniter is at place 2 and 20 is at place 3.
To get the category you have to pass 1, for codeigniter pass 2 and for 20 you have to pass the 3 to $this->uri->segment() method.
-
Example code to get the URI segment in codeigniter
Here we have an URL and we can get the URL segments (category, codeigniter, 20) by passing the number to
$this->uri->segment()
method at which place they are exist.URI
http://example.com/category/codeigniter/20
To get the vlaue of category
$this->uri->segment(1)
To get the vlaue of codeigniter
$this->uri->segment(2)
To get the value of 20 from URI
$this->uri->segment(3)
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: CodeIgniter
- Call to undefined function CodeIgniter\locale_set_default()
- Get last executed query in codeigniter
- How to load a view in CodeIgniter?
- Unable to set session in codeigniter
- How to get field names of table in Codeigniter
- Update an existing table record with +1 in CodeIgniter
- Get the version codeIgniter
- Codeigniter 4 call model function from controller
- No input file specified Codeigniter
- How to select all checkbox in Codeigniter
- How to create custom helper in codeigniter 4
- Default htaccess file code Codeigniter
- Convert dd/mm/yyyy to yyyy-mm-dd in codeigniter
- How to call helper function in Codeigniter view
- How to move from one view to another in Codeigniter