concept of superglobal variable in php

which superglobal variable have access to get, post and cookies value?


2 Answers
1-2 of  2
2 Answers
  • All superglobal variables have access to get , post and cookies .

    Superglobal variables are $GLOBAL,$_POST,$_GET,$_SERVER,$_REQUEST,$_SESSION,$_COOKIE,$_FILES.

  • 1. $GLOBALS is a PHP super global variable which is used to access global variables from 
         anywhere in the PHP script.
     2. PHP stores all global variables in an array called $GLOBALS[index]. The index holds the 
         name of the variable.
     3. Program: 
    <!DOCTYPE html>
    <html>
    <body>
    <?php 
    $x = 36;
    $y = 25; 
    function addition() {
        $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];
    }
    addition();
    echo $z;
    ?>
    </body>
    </html>
    Output: 61

PHP

Didn't get the answer.
Contact people of Talent-PHP directly by clicking here