- Original Message -
From: "John" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 16, 2001 9:12 PM
Subject: Re: [PHP] Strange PHP Reference behaviour with globals
> Thanks Yasuo,
>
> That might explain why $gGlobal is not permanently set to
Thanks Yasuo,
That might explain why $gGlobal is not permanently set to 99,
but that doesn't explain why $gGlobal is set to 55 in ChangeGlobalValue()
permanently. So are you or am I missing something?
Bye, John
""Yasuo Ohgaki"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL
This is expected behavior of PHP's reference. Reference works like a pointer,
but it dose NOT works like a pointer. This is case that reference does not
works as many programmer expected.
I think this is in manual.
Hint: when programmer use 'global $var'. It is the same as do '$var = &
$GLOBALS[
Hello,
Try the following code:
";
}
function ChangeGlobalRef()
{
global $gGlobal;
$local = 99;
$gGlobal = &$local;
print "Ref:Global=$gGlobal";
}
print "Global=$gGlobal";
ChangeGlobalValue();
print "Global=$gGlobal";
ChangeGlobalRef();
print "Global=$gGlobal";
?>
I get the following results:
4 matches
Mail list logo