Accessing Global Variables with the global Statement : GLOBALS « Language Basics « PHP






Accessing Global Variables with the global Statement

 
<html>
<head><title>The global Statement</title></head>
<body>
<div>
<?php
    $life=42;
    
    function meaningOfLife() {
      global $life;
      print "The meaning of life is $life<br />";
    }
    meaningOfLife();
?>
</div>
</body>
</html>
  
  








Related examples in the same category

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