Re: PHP globals aren't really globals
| From: | John Vanderbeck | Date: | Wed, 14 Feb 2001 15:07:15 +0000 |
| Subject: | Re: PHP globals aren't really globals | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39635@lists.php.net to get a copy of this message | ||
> Perhaps I'm missing something. In order to access the value of any
> variable defined outside the scope of the function, you have to declare
> it as "global". This is true in every single instance. If you do not,
then
> you cannot access the value of that variable. While it's been a while
> since I've worked with C, I seem to recall it being the case there as
> well. And in Pascal. And in VB. Again, it's been a while so I could be
> wrong (but don't think so).
Not realy. In most languages, heck , all I can think of, the variable's
scope is simply dependant on WHERE it was declared, not how it was declared.
If in C/C++ you define a variable outside the scope of any function, then it
becomes global and can be accessed by any function.
I'm not arguing one side or the other, just stating :) I personally find the
PHP way a bit annoiying, but its workable, and i'm SURE there was a reason
for it. Just not sure what that reason was :)
- John Vanderbeck
- Admin, GameDesign
>
> Chris
>