How can I add GET variables to the end of the current page url using a form with php?

眉间皱痕 提交于 2019-12-02 01:26:47

Try this:

if (strpos($_SERVER['REQUEST_URI'], '?') !== false)
{
  $url = $_SERVER['REQUEST_URI'] . '&var=value';
}
else
{
  $url = $_SERVER['REQUEST_URI'] . '?var=value';
}

<a href="<php echo $url;>">Go</a>

Note that $_SERVER['REQUEST_URI'] gives you current url including query string value.

$query_string = http_build_query(array_merge($_GET, array('page' => $page)));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!