note 12494 deleted from language.variables.scope by jimw

From: Date: Sat, 08 Dec 2001 21:46:04 +0000
Subject: note 12494 deleted from language.variables.scope by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22234@lists.php.net to get a copy of this message
As of version 4.0.1pl2, I found something interesting: If you do the following - function foo () { global $GLOBALS; $GLOBALS["hello"] = "world!"; } foo (); echo ($hello); // then it will print NOTHING! To work around this problem (bug??), I had to do - $GLOBALS["dummy"] = ""; // *** NEW *** function foo () { global $GLOBALS; $GLOBALS["hello"] = "world!"; } foo (); echo ($hello); // which prints "world!" as desired. It seems that the $GLOBALS array needs to be set explicitly before being able to set its values from a function. Also, using $dummy = "" instead doesn't seem to work.

« previous php.notes (#22234) next »