$GLOBALS is a PHP super global variable which can be used
instead of global keyword to a access variable from global scope. By this array
we can use any global variable in global scope by PHP script. All global
variables are stored in GLOBALS Array. Many times PHP Programmer facing Problem
while they use variable in the method because variable cannot access in the
method easily with using PHP script. If we want to use this variable in the
method they we have to use this super global array $GLOBAL in PHP script.
Example 1:
<?php
$v=”Hello welcome to world”;
function demo( )
{
echo $GLOBALS[‘v’];
}
demo( );
?>
Example 2:
<?php
$a=35;
$b=40;
function addition ( )
{
$GLOBALS[‘c’]=$GLOBALS[‘a’]+ $GLOBALS[‘b’];
}
addition ( );
echo $c;
?>
Here Video Tutorial