View Single Post
Old 05-12-2009, 08:30 PM   #3 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Generally in programming, global variables are those which are accessible in every scope. So when the author says that PHP does not support them, it is true. Take care not to confuse "global variables" with "variables in the global scope": when talking about global variables in PHP that distinction is often blurred.

Global variables (are not supported)
PHP Code:
$global 'my global variable';
function 
test()
{
  echo 
$global;
}
test(); // Notice:  Undefined variable: global ... 
The quote in the second post is referring only to the superglobal variables. To put it into context, a fuller quote is:
On a language level, it is important to know that you can access these [superglobal] variables anywhere in your script whether function, method, or global scope. You don’t have to use the $GLOBALS[] array, which allows for accessing global variables without having to predeclare them or using the deprecated globals keyword.
Salathe is offline  
Reply With Quote