Get URL query string parameters

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

    The PHP way to do it is using the function parse_url, which parses a URL and return its components. Including the query string.

    Example:

    $url = 'www.mysite.com/category/subcategory?myqueryhash';
    echo parse_url($url, PHP_URL_QUERY); # output "myqueryhash"
    

    Full documentation here

提交回复
热议问题