Home >>PHP Tutorial >PHP Super global variables

PHP Super global variables

Super Global Variables in PHP

PHP super global variable is used to access global variables from anywhere in the PHP script. PHP Super global variables is accessible inside the same page that defines it, as well as outside the page. while local variable's scope is within the page that defines it.

The PHP super global variables are :

1) $_GET["FormElementName"]

It is used to collect value from a form(HTML script) sent with method='get'. information sent from a form with the method='get' is visible to everyone(it display on the browser URL bar).

2) $_POST["FormElementName"]

It is used to collect value in a form with method="post". Information sent from a form is invisible to others.(can check on address bar)

3) $_REQUEST["FormElementName"]

This can be used to collect data with both post and get method.

4) $_FILES["FormElementName"]

: It can be used to upload files from a client computer/system to a server. OR

$_FILES["FormElementName"]["ArrayIndex"]

: Such as File Name, File Type, File Size, File temporary name.

5) $_SESSION["VariableName"]

A session variable is used to store information about a single user, and are available to all pages within one application.

6) $_COOKIE["VariableName"]

A cookie is used to identify a user. cookie is a small file that the server embedded on user computer.

7) $_SERVER["ConstantName"]

$_SERVER holds information about headers, paths, and script locations.

Eg

  $_SERVER["SERVER_PORT"]

$_SERVER["SERVER_NAME"]

$_SERVER["REQUEST_URI"]


No Sidebar ads