Okay, I\'m not sure I\'m understanding this concept properly (I\'m learning PHP). If I understand correctly: Global variables can be referenced anywhere in the same document
In programming, there are many cases where you need a variable only in an isolated context. Counters, function arguments and variables for storing interim results of calculations and such, those aren't of any interest in the whole application. Furthermore, there's the special case of recursive functions. Local variables will get their own distinct addresses for each instance of the recursive function, which is a necessity for recursion to work properly. In PHP applications, however, it's advisable to avoid using global variables wherever you can.