PHP Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 3.00

Information in $_GET and $_REQUEST

This section provides a tutorial example on how to dump information stored in the $_GET array and the $_REQUEST array.

Now try this URL, http://localhost/HttpRequestDetails.php?lang=PHP&search. You should get:


Contents of $_GET:
   lang = PHP
   search = 

Contents of $_POST:

Contents of $_COOKIE:

Contents of $_REQUEST:
   lang = PHP
   search = 

Contents of $_SERVER:
   ......
   QUERY_STRING = lang=PHP&search
   ......

Notice that:

  • "?lang=PHP&search" attached at the end of the URL represents information submitted with the GET method.
  • "?lang=PHP&search" is parsed by the PHP engine into 2 pairs of names and values and stored in the $_GET array.
  • The PHP engine copied the same information from $_GET to $_REQUEST.

Exercise: Try to find a way to test how to provide information with the POST method and how to provide cookies.

Last update: 2005.

Sections in This Chapter

Predefined Variables Related to HTTP Requests

Operating System Information in $_SERVER

Web Server Information in $_SERVER

Information in $_GET and $_REQUEST

Registering $_REQUEST Keys as Global Variables

Dr. Herong Yang, updated in 2009
Information in $_GET and $_REQUEST