05-12-2009, 08:42 PM
|
#4 (permalink)
|
|
The Gregarious
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
|
Quote:
Originally Posted by Salathe
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.
|
Fantastic....understand now.....
I will be looking forward to your book:
Mastering PHP by Salathe
 
|
|
|
|