Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

drupal

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

like image 805
user550265 Avatar asked Jan 19 '11 01:01

user550265


People also ask

What is $_ SERVER [' Request_uri ']?

$_SERVER['REQUEST_URI'] contains the URI of the current page. So if the full path of a page is https://www.w3resource.com/html/html-tutorials.php, $_SERVER['REQUEST_URI'] would contain /html/html-tutorials. php.

What is $_ SERVER [' PHP_SELF ']?

$_SERVER['PHP_SELF'] Returns the filename of the currently executing script. $_SERVER['GATEWAY_INTERFACE'] Returns the version of the Common Gateway Interface (CGI) the server is using.

What is $_ SERVER [' Script_name ']?

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.

Is $_ SERVER [' Request_uri '] safe?

In cases where you do need it, the answer is that yes, REQUEST_URI is safe.


1 Answers

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.

like image 123
Decent Dabbler Avatar answered Oct 22 '22 14:10

Decent Dabbler