the global keyword just means that the variable is accessible to all functions. so we could have.
<?php
GLOBAL $foo="bar";
function baz()
{
....GLOBAL $foo;
....print $foo;
}
here calling baz() will print "bar". if we omit the GLOBAL calls like so.
$foo="bar";
function baz()
{
....print $foo;
}
we get nothing because $foo is null.
it all comes down to variable scope. variables inside of functions only live inside the function. the minute the program leaves the function the variable evaporates. this is a Good Thing, since without this scope we'd be accidentally writing over valuable variables all the time and, worse, the memory requirements for large scripts would be astronomical (well, big at least).
GLOBAL is just a way to say that the scope of the variable defined as global has unlimited scope.
NOTE: there are purists out there that say that global variables are bad form. while this is just a hold over from the days when ram was scarce, it is true that if you have a lot of globals it becomes tough to keep track of them all. I usually put globals in upper case so i can always tell them from locals.
-frymaster