According to the most programming languages scope rules, I can access variables that are defined outside of functions inside them, but why doesn\'t this code work?
I find it straightforward and easy to follow. The $GLOBALS is how PHP lets you reference a global variable. If you have used things like $_SERVER, $_POST, etc. then you have reference a global variable without knowing it.