PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
bindermichi wrote:Hmm... as far as i read the manual, there's a difference between "$GLOBALS[''];" and "global $var;"
By declaring $a and $b global within the function, all references to either variable will refer to the global version.
Notice how $GLOBALS exists in any scope, this is because $GLOBALS is a superglobal.
...and if I learned one thing in programming class... it's never to use superglobals, unless you have to
I believe you are confusing two ways of accessing a global variable (though the global keyword and through the $GLOBALS superglobal) with the concept that globals are bad. This is the case (that you should try to avoid the use of global variables) but you ARE still using them with either method of access. Changing how you access a global varaible does not reduce your dependancy on it.
In my own code I entirely avoid the global keyword. I would much rather grab a global from the big, ugly $GLOBALS['some_var'] as a constant reminder to me that I should be execising caution when doing so.
sweatje wrote:
I believe you are confusing two ways of accessing a global variable (though the global keyword and through the $GLOBALS superglobal) with the concept that globals are bad. This is the case (that you should try to avoid the use of global variables) but you ARE still using them with either method of access. Changing how you access a global varaible does not reduce your dependancy on it.
In my own code I entirely avoid the global keyword. I would much rather grab a global from the big, ugly $GLOBALS['some_var'] as a constant reminder to me that I should be execising caution when doing so.
K, ... guess it's monday after all
Well, it works with the global array, so I guess for debugging the functions this will do.