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

前端 未结 2 550
我寻月下人不归
我寻月下人不归 2021-01-21 17:36

I have some database information that is being shown on a page.

I am using a pagination class that uses the $_GET[\'page\'] variable in the url. When you c

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-21 17:59

    Try this:

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

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

提交回复
热议问题