note 93186 deleted from language.variables.scope by danbrown

From: Date: Mon, 17 Oct 2011 16:21:51 +0000
Subject: note 93186 deleted from language.variables.scope by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-183927@lists.php.net to get a copy of this message
Note Submitter: pike ---- While writing php code that was served as a "view" from within a cms (in my case ezpublish), the "global" keyword seemed to have stopped working in php5. example #1 on this page simply returned "2", not "3". However, the error was somewhere else. Since my php code was included within other code by the CMS, the first assignments (a=1,b=2) were apparently not really in the global scope, and hence could not be referenced by the keyword "global" in php5. This worked in php4. In my particular case, prepending <code> global $a,$b; </code> to the code (which is invalid php in a root context afaik) fixed it. $2c, *-pike

« previous php.notes (#183927) next »