Re: global variables in php4 code
| From: | Lukas Kahwe Smith | Date: | Mon, 08 Oct 2007 13:03:20 +0000 |
| Subject: | Re: global variables in php4 code | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-48237@lists.php.net to get a copy of this message | ||
On 08.10.2007, at 14:59, Chuck Burgess wrote:
On 10/8/07, Lukas Kahwe Smith <mls@pooteeweet.org> wrote:the problem is that if you require the code inside the function, then the variable is not really global, but instead is defined inside the function scope. so if you then call a function from outside of that function call, then the "global $foo" inside the methods of the package will not actually import the variable you expected. regards, Lukasthat global $_Text_Password_NumberOfPossibleCharacters var definition seems incorrect to me. it should use $GLOBALS explicitly as otherwise it might cause issues if included inside a function. thoughts?I'm curious about what possible problems this raises. Some PHP4 code I have to work on includes several global variables, that are constantly being referenced everywhere. I've somewhat avoided it, in that I'll wrap a particular global with a get() method, and in all the remaining functions just use what that get() returns, rather than referencing the global variable directly anywhere else but inside the get() method. So, if there are gotchas out there in referencing a global variable like global $MyGlobal; without using the $GLOBALS array, I need to understand.