what is the difference between $_SERVER['REQUEST_URI'] and $_GET['q']?

user550265 picture user550265 · Jan 19, 2011 · Viewed 158.8k times · Source

what is the difference between $_SERVER['REQUEST_URI'] and $_GET['q'] (which is used in Drupal)?

Answer

Decent Dabbler picture Decent Dabbler · Jan 19, 2011

Given this example url:

http://www.example.com/some-dir/yourpage.php?q=bogus&n=10

$_SERVER['REQUEST_URI'] will give you:

/some-dir/yourpage.php?q=bogus&n=10

Whereas $_GET['q'] will give you:

bogus

In other words, $_SERVER['REQUEST_URI'] will hold the full request path including the querystring. And $_GET['q'] will give you the value of parameter q in the querystring.