Get URL query string parameters

前端 未结 11 1428
长情又很酷
长情又很酷 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:49

    Also if you are looking for current file name along with the query string, you will just need following

    basename($_SERVER['REQUEST_URI'])
    

    It would provide you info like following example

    file.php?arg1=val&arg2=val

    And if you also want full path of file as well starting from root, e.g. /folder/folder2/file.php?arg1=val&arg2=val then just remove basename() function and just use fillowing

    $_SERVER['REQUEST_URI']
    

提交回复
热议问题