How to get id from URL in codeigniter?
In CodeIgniter, you can get the value of the id from the URL by using the function $this->uri->segment(n)
, where n
is the position of the segment you want to retrieve. For example, if the URL is example.com/controller/function/id
, you can use $this->uri->segment(3)
to get the value of the id.
You can also use $this->input->get('id')
to get the value of the id if the URL is like example.com/controller/function?id=1
.
You can also use $this->input->post('id')
if you are trying to get the id from a form submit with method post.