Get URL query string parameters

前端 未结 11 1462
长情又很酷
长情又很酷 2020-11-22 17:41

What is the \"less code needed\" way to get parameters from a URL query string which is formatted like the following?

www.mysite.com/category/subcateg

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 17:44

    Thanks to @K. Shahzad This helps when you want the rewrited query string without any rewrite additions. Let say you rewrite the /test/?x=y to index.php?q=test&x=y and you want only want the query string.

    function get_query_string(){
    
        $arr = explode("?",$_SERVER['REQUEST_URI']);
        if (count($arr) == 2){
            return "";
        }else{
            return "?".end($arr)."
    "; } } $query_string = get_query_string();

提交回复
热议问题