06-08-2008, 01:52 PM
|
#4 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
It's not called renaming, it's simply a statement to help the parser understand what is the variable that needs to be modified (is it coming from the namespace or is it coming from the current function -- the latter is assumed by default).
PHP Code:
$a = 5;
function showA() { global $a; // not renaming anything, just letting the parser know that the $a is declared globally, and use its value, instead of defining a function-level variable called $a
$a = 10; }
showA(); echo $a; // will output 10, but if you remove the global statement (or comment it), it will output 5, of course
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
|
|
|
|