Re: global variables in php4 code
| From: | Lukas Kahwe Smith | Date: | Mon, 08 Oct 2007 13:19:32 +0000 |
| Subject: | Re: global variables in php4 code | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-48239@lists.php.net to get a copy of this message | ||
On 08.10.2007, at 15:12, Chuck Burgess wrote:
On 10/8/07, Lukas Kahwe Smith <mls@pooteeweet.org> wrote:the main problem is the definition of the variable. but i also think there is potential issues when importing the variable. i do not remember exactly, because i moved to using $GLOBALS everywhere long ago. regards, Lukasbut instead is defined inside the function scopeI thought that this usage indicated that the actual global variable declaration was done somewhere else, and the only way to use the global from inside your class/method block was to mention it via the "global" command, almost like it really meant "import $MyGlobal". So, my understanding was the variable is being declared/set elsewhere, and is only being imported into the class/method block via the "global" command. How does -> global $MyGlobal; differ from -> global $GLOBALS['MyGlobal']; in this scenario? Is there a danger that you've inadvertently redeclared $MyGlobal somewhere in your local code, not intending for it to replace $GLOBALS['MyGlobal'], meaning it's possible that both could exist separately?