Get value from url codeigniter

我们两清 提交于 2020-01-04 06:21:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!