note 65337 deleted from language.variables.scope by danbrown

From: Date: Mon, 18 May 2009 01:36:18 +0000
Subject: note 65337 deleted from language.variables.scope by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155560@lists.php.net to get a copy of this message
Note Submitter: jason ---- This is probably self-evident to most folks here, and I expected this behavior, but it wasn't explicitly mentioned in the manual itself so I tested to find out: the global keyword *will* allow you to access variables in the global scope of your script, even if those variables were not made available locally to the parent function. In other words, the following will work as expected, even though $a is never referenced as global within the function foo: <?php function foo() { bar(); } function bar() { global $a; echo $a; } $a = "works!"; foo(); ?>

« previous php.notes (#155560) next »