What is the "less code need" way to get parameters from URL query string which is formatted like this:

www.mysite.com/category/subcategory?myqueryhash

Output should be: myqueryhash

I aware of this approach:

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

<?php
   echo $_GET['q'];  //output: myquery
?>
share|improve this question

2 Answers

up vote 29 down vote accepted

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

PHP: $_SERVER - Manual

share|improve this answer
3  
print_r($_SERVER) to find related values – Dagon Dec 12 '11 at 3:58
+1 for the link! Thanks! – JToland Oct 11 '12 at 1:32

If you want the whole query string:

$_SERVER["QUERY_STRING"]
share|improve this answer

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.