$GLOBALS in PHP

What is $GLOBALS in PHP ?

$GLOBALS is a PHP super global variable which is used to access global variables from anywhere in the PHP script. PHP stores all global variables in an array called $GLOBALS[index]. The index holds the name of the variable.

  
<?php
function display()
{
$GLOBALS[\'v\'] =\"india\";
}
display();
echo $v;

?>
 

since v is a variable present within $GLOBALS array, it is accessible form outside the function also.

Scroll to Top