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

后端 未结 3 1156
谎友^
谎友^ 2020-12-05 00:37

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

3条回答
  •  心在旅途
    2020-12-05 00:59

    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.

提交回复
热议问题