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:

Note that if you are migrating scripts older than PHP 5.4.0, you may see a sudden change on how quotes are passed in $_POST, $_COOKIE, and $_REQUEST.

Before PHP 5.4.0, the PHP engine has a default option called "magic_quotes_gpc", which turns on the "magic_quotes" state for GPC GPC (Get/Post/Cookie) operations. When "magic_quotes" state is on, all ' (single-quote), " (double quote), \ (backslash) are escaped with a backslash automatically.

So scripts older than PHP 5.4.0 are using stripslashes() function calls to clean up values received in $_POST, $_COOKIE, and $_REQUEST.

Now you must remove those stripslashes() function calls from older script. If not removed, values received from client side may get damaged. For example, "\\" will be received as "\".

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

Table of Contents

 About This Book

 Introduction and Installation of PHP 7.3

 PHP Script File Syntax

 PHP Data Types and Data Literals

 Variables, References, and Constants

 Expressions, Operations and Type Conversions

 Conditional Statements - "if" and "switch"

 Loop Statements - "while", "for", and "do ... while"

 Function Declaration, Arguments, and Return Values

 Arrays - Ordered Maps

 Interface with Operating System

 Introduction of Class and Object

 Integrating PHP with Apache Web Server

Retrieving Information from HTTP Requests

 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

 Creating and Managing Sessions in PHP Scripts

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 Managing File Upload

 MySQL Server Connection and Access Functions

 Functions to Manage Directories, Files and Images

 SOAP Extension Function and Calling Web Services

 SOAP Server Functions and Examples

 Localization Overview of Web Applications

 Using Non-ASCII Characters in HTML Documents

 Using Non-ASCII Characters as PHP Script String Literals

 Receiving Non-ASCII Characters from Input Forms

 "mbstring" Extension and Non-ASCII Encoding Management

 Managing Non-ASCII Character Strings with MySQL Servers

 Parsing and Managing HTML Documents

 Configuring and Sending out Emails

 Image and Picture Processing

 Managing ZIP Archive Files

 Managing PHP Engine and Modules on macOS

 Managing PHP Engine and Modules on CentOS

 Outdated Tutorials


 Full Version in PDF/EPUB