At 09:24 27.03.2003, Marek Kilimajer said:
[snip]
echo GLOBALS['$key'] = $valuebr\n;
is right because $key is in double quotes (the outermost qoutes)
[snip]
...almost... the array deref should be in curly quotes
At 09:46 27.03.2003, Marek Kilimajer said:
[snip]
there is no $ in front of GLOBALS ;)
[snip]
right you are - I noticed it as soon as the message was out... sometimes
one's too fast hitting the send button ;-)
--
.
-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2003 1:16 PM
To: Daevid Vincent
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] What am I not understanding about
$GLOBALS['myvar'] vs global $myvar?
Daevid Vincent wrote:
This one
I think you either want to use no quotes or double quotes, but not single
quotes. Double quotes will interpolate the variable, single quotes will not,
i.e. $key becomes a string literal rather than a variable. No quotes will
work, although the docs seem to indicate it is deprecated syntax. Not
Actually I didn't. ;-)
$GLOBALS[$key] is incorrect and depricated AFAIK.
$GLOBALS['$key'] (with the single quotes) is the proper way to write these
Wouldn't it need to be $GLOBALS[$key] because single quotes tell the
parser not to expand variables? I think you are misinterpreting the part of
No, you misunderstand. The key is simply a string. Just as print
foo; is wrong, $array[foo] is wrong (unless foo is a constant, of
course). If you do print '$variable';, it will print the literal
string $variable. It will not print the value of $variable. You
should either use double
6 matches
Mail list logo