Addressed to: Maxim Maletsky <[EMAIL PROTECTED]>
[EMAIL PROTECTED]
Christian Dechery [mailto:[EMAIL PROTECTED]]
** Reply to note from Maxim Maletsky <[EMAIL PROTECTED]> Fri, 16 Feb 2001
12:18:27 +0900
>
> I never used 50 of them, but I think there's such a thing as 'r
Cheers,
Maxim Maletsky
-Original Message-
From: Christian Dechery [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 14, 2001 11:25 PM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP globals aren't really globals
I've been programming in C all my life, and now I just started developing
in
It's somewhat annoying to have to tell the function which variables are
global sometimes but overall it makes it easier to avoid stupid
mistakes. It is a good push to make me less prone to making things
global. Usually I just avoid using globals and then pack what I do use
into appropiate arra
> I believe you use globals $var to ACCESS a global variable, not to
> define.
That's correct. To be perfectly correct here, what you are doing is
creating a reference to the global variable. Think of it as an alias to
the same variable as the global variable.
global $foo;
would be equiva
I believe you use globals $var to ACCESS a global variable, not to
define.
If I understand correctly, and please correct me if I am wrong, this a
way to ge around the name space...
ex. for something like
$my_var = 10;
function test () {
$my_var = 15;
}
because of these vari
>The idea is to avoid really nasty scope-related bugs that are common in
>C
>code that uses lots of global variables. Years and years ago when I wrote
>the first version of PHP I was working for a telco writing software for
>a
>large telephone switch. The code was huge and extremely ugly. Glob
> Rasmus wrote:
> >I swore I would not have the same problem in PHP and thus the
requirement
> >for people to be explicit about using global variables inside functions.
> >Hopefully it also forces a little bit of structure and organization on
> >people.
>
> Hear, hear and thank you Rasmus. It
Rasmus wrote:
>I swore I would not have the same problem in PHP and thus the requirement
>for people to be explicit about using global variables inside functions.
>Hopefully it also forces a little bit of structure and organization on
>people.
Hear, hear and thank you Rasmus. It seems to me t
> 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
>
> I've been programming in C all my life, and now I just started developing
> in PHP and I'm really enjoying it, it has all the missing improvements that
> C needed to be more user-likely.
>
> But one thin I can't get, how can PHP call a variabel global, if it isn't
> global.
> A global var, is a
> >Yes. But with regards to form variables, all you need to do is
> >make one variable global:
> >$HTTP_POST_VARS
> >it is an associative array that contains all the post variables from
> >the form. Make it global and just loop through it.
> exactly, u need to loop to an array to get the globa
>> function u want to use it. THis is not nice, what about if u
>> have a form with 50 fields and want a function to validate
>> all of them, u have to pass them all to the function or build
>> a little piece of code to make all the $GLOBALS local right?
>> Is this really the idea of global vars?
> function u want to use it. THis is not nice, what about if u
> have a form with 50 fields and want a function to validate
> all of them, u have to pass them all to the function or build
> a little piece of code to make all the $GLOBALS local right?
> Is this really the idea of global vars?
Y
At 11:24 AM -0300 2/14/01, Christian Dechery wrote:
>I've been programming in C all my life, and now I just started developing
>in PHP and I'm really enjoying it, it has all the missing improvements that
>C needed to be more user-likely.
>
>But one thin I can't get, how can PHP call a variabel glo
I've been programming in C all my life, and now I just started developing
in PHP and I'm really enjoying it, it has all the missing improvements that
C needed to be more user-likely.
But one thin I can't get, how can PHP call a variabel global, if it isn't
global.
A global var, is a var defined o
15 matches
Mail list logo