note 101385 deleted from language.variables.scope by danbrown

From: Date: Tue, 14 Dec 2010 15:29:37 +0000
Subject: note 101385 deleted from language.variables.scope by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-174910@lists.php.net to get a copy of this message
Note Submitter: Dave ---- Regarding "php at keith tyler dot com" note about global scope - the $filename variable is clearly not actually in global scope. It is in the scope that phpunit runs the unit tests, which is local scope. Your "fix" simply creates a global variable called "filename" with the contents of the *local* variable "filename". To illustrate: file1.php: <?php class Foo { static public function bar() { global $filename; return $filename; } } ?> run.php: <?php $filename = 'mia'; include('file1.php'); assert( null === Foo::bar() ); ?> In the "run.php" file, Foo::bar() will return NULL, because $filename is in local scope.

« previous php.notes (#174910) next »