concept of superglobal variable in php

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

  • Snehal
  • 20 Jul 2018
  • 852 Views
  • 2 Answers
Your Answer

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