Modifying a Variable with $GLOBALS : GLOBALS « Language Basics « PHP






Modifying a Variable with $GLOBALS

 
<?
$dinner = 'Curry';

function hungry_dinner() {
    $GLOBALS['dinner'] .= ' and Fried';
}

print "Regular dinner is $dinner";
print "\n";
hungry_dinner();
print "Hungry dinner is $dinner";
?>
  
  








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.Global vs function level
7.Overriding Scope with the GLOBALS Array