Hello,
Try the following code:
?php
$gGlobal = 1;
function ChangeGlobalValue()
{
global $gGlobal;
$local = 55;
$gGlobal = $local;
print "Value:Global=$gGlobalBR";
}
function ChangeGlobalRef()
{
global $gGlobal;
$local = 99;
$gGlobal = $local;
print "Ref:Global=$gGlobalBR";
}
print
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 =
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
- 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 99,
but that doesn't e
4 matches
Mail list logo