ankitweblogic logo
W e b t u t o r i a l s

Define PHP

PHP Installation


PHP Case Sensitivity

PHP Variable

PHP Echo & Print

PHP Operators

PHP Receiving Input

PHP Decision Making

PHP Loops

PHP Jumping Statement

PHP Image Gallery

PHP Arrays

PHP File Upload

PHP String Functions

PHP Math Functions

PHP Functions

PHP Variable Scope

PHP Constant Variable

PHP Superglobals

PHP Form Validation

PHP Include Statement

PHP Filter

PHP File Handling

PHP Date Functions

PHP Cookies

PHP Session

PHP Send Emails

PHP Captcha

PHP-MySQL Connectivity

PHP MySQL Select

PHP MySQL Insert

PHP MySQL Delete

PHP MySQL Update

PHP MySQL Injection

PHP superglobals

Superglobals were introduced in PHP 4.1 Version, All superglobals and are built-in variables and are always available in all the scopes.
The PHP superglobal variables are:


$_SERVER is a PHP super global variable which holds information about Server IP Address, Server Name, PHP File, PHP File Path, Request Method, Query String.

Superglobal Variables Description
$_SERVER['PHP_SELF'] Returns the current filename
$_SERVER['SERVER_ADDR'] Returns the IP address of the host server
$_SERVER['SERVER_NAME'] Returns the name of the host server (website name)
$_SERVER['SERVER_SOFTWARE'] Returns the server software (Apache)
$_SERVER['REQUEST_METHOD'] Returns the request method used to access the page (GET/POST)
$_SERVER['QUERY_STRING'] Returns the query string if the page is accessed via a query string
$_SERVER['REMOTE_ADDR'] Returns the IP address of the user computer
$_SERVER['SCRIPT_FILENAME'] Returns the absolute pathname (full path) of the current php file
$_SERVER['SCRIPT_NAME'] Returns the name of the current php file


PHP $_REQUEST is used to collect data after submitting an HTML form.


A Querystring (also called an HTTP querystring) is the set of characters automatically input in the address bar. Querystring is a way of passsing value with the URL(Uniform Resource Locator), the querystring follows a separating character, a question mark(?), and the data to be pass.

Example 1: Query String
<a href="page2.php?value"> click </a>
    echo $_SERVER['QUERY_STRING'];
Example 2: Query String with variable
<a href="page2.php?a=10"> click </a>
    echo $_GET['a'];
Example 3: Query String with 2 variables.
<a href="page2.php?a=10&b=20"> click 
    echo $_GET['a'];
    echo $_GET['b'];
Example 4: Query String with input variables
	<a href="page2.php?a=<?php echo urlencode($x);?>&b=<?php echo urlencode($y);?>"> click </a>
	echo $_GET['a'];
	echo $_GET['b'];