PHP Tutorial Tutorials - PHP Superglobal variables

PHP Superglobal variables

Superglobal variables are available in all scopes throughout a script.

The PHP super global variables are :
$GLOBALS
$_SERVER
$_GET
$_POST
$_FILES
$_COOKIE
$_SESSION
$_REQUEST
$_ENV

the most frequently used of these are:

  1. $_SERVER['QUERY_STRING']
    The query string, if any, via which the page was accessed.
  2. $_GET[“FormElementName”]
    It is used to collect value from a form with method='get'.
  3. $_POST[“FormElementName”]
    It is used to collect value in a form with method='post'.
  4. $_REQUEST[“FormElementName”]
    This can be used to collect data with both post and get method
  5. $_SERVER['PHP_SELF']
    The filename of the currently executing script,example:http://lautturi.com/foo/bar.php(/foo/bar.php)
  6. $_FILES
    HTTP File Upload variables
  7. $_SESSION['variableName']
    It is used to store session information
  8. $_COOKIE
    HTTP Cookies

you can use var_dump() to get more information

<?php
var_dump($GLOBALS);
var_dump($_SERVER);
?>
Date:2019-09-30 18:18:27 From:www.Lautturi.com author:Lautturi