Get URL query string parameters

enloz picture enloz · Dec 12, 2011 · Viewed 823.2k times · Source

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/subcategory?myqueryhash

Output should be: myqueryhash

I am aware of this approach:

www.mysite.com/category/subcategory?q=myquery

<?php
   echo $_GET['q'];  //Output: myquery
?>

Answer

Filip Ros&#233;en - refp picture Filip Roséen - refp · Dec 12, 2011

$_SERVER['QUERY_STRING'] contains the data that you are looking for.


DOCUMENTATION