Re: getting variables from other functions
| From: | CC Zona | Date: | Sun, 21 Jul 2002 05:51:24 +0000 |
| Subject: | Re: getting variables from other functions | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108707@lists.php.net to get a copy of this message | ||
In article <3D3A3ABA.2030705@peak.org>, luomat@peak.org (Tim Luoma) wrote:
> > If you had did that you will see that they are both empty. Which means that
> > you forgot to declare them as global.
>
> I had the mistaken notion that once a variable had been defined as
> 'global' in one function that it was then available for the rest of the
> PHP script.
You've fallen into a common terminology trap: we talk about that keyword as
"declaring a global" or "declaring as global", when that keyword's purpose
would be better described as "declaring that when making reference to the
following variable(s), I mean the one(s) in the global namespace rather
than this function's local namespace." Use of the "global" keyword doesn't
change a variable's namespace, so much as it calls out to the specified
namespace.
--
CC