Global vs function level : GLOBALS « Language Basics « PHP






Global vs function level

 
<?php 
$a = 7; 
function test() { 
    global $a; 
    $a = 20; 
} 
test(); 
echo "\$a = $a\n"; 
?>
  
  








Related examples in the same category

1.Set new value into GLOBALS values
2.Looping Through the $GLOBALS Array
3.$GLOBALS with property
4.Accessing Global Variables with the global Statement
5.Create global variables
6.Modifying a Variable with $GLOBALS
7.Overriding Scope with the GLOBALS Array