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!
I was having trouble accessing a global in one of my functions. The global is an array named $config. If you will, please note the following chunk of code...
$GLOBALS is a "superglobal" ie it can be acessed anywhere from any scope.
$config is itself just an ordinary array in the global scope. It doesn't exist within the function scope unless you pass it in or access it directly from the superglobal $GLOBALS:
What about the register_globals?
"Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP 4.2.0." http://php.planetmirror.com/manual/en/s ... lobals.php
Hmm... This works, and $GLOBALS['config']['whatever'] lets me access the values in that array. Thank you.
Okay, so... global variables in PHP aren't really global, or... ? Why did the PHP team find the need to do globals different from every other programming lang in the universe?