问题
I have a domain and id is coming in that domain like this http://www.test.com/update_record_row/id/6356/
I want id value from the domain without passing ? instead of / in (query string)
回答1:
<a href="http://www.test.com/update_record_row/6356/"> ID </a>
public function update_record_row($id)
{
echo "Id is :".$id;
}
or
Use URI segment
// if URL -http://www.test.com/update_record_row/id/6356/
$id = $this->uri->segment(3);
// if URL -http://www.test.com/update_record_row/6356/
$id = $this->uri->segment(2);
回答2:
Using $this->uri->segment()
you get the URL parameter
$this->uri->segment(1)
For more ..https://www.codeigniter.com/userguide3/libraries/uri.html
回答3:
Use $this->uri->segment() to retreive passed value through url
If URL is http://www.test.com/update_record_row/id/6356/
You should use $this->uri->segment(3);
Codeigniter has awesome userguide.Just check this in in uri part. https://www.codeigniter.com/userguide3/libraries/uri.html#uri-class
来源:https://stackoverflow.com/questions/40189590/get-value-from-url-codeigniter