function test(&$a)
{
$a = $a + 3;
}
If I assign the variable first and call it:
$a = 3;
test($a);
echo $a; //it will output 6
but if I do this
test($a = 3);
echo $a; //it will return 3
Why is that? Doesnt’ the reference variable in the second function call modify it to be 6 as well?
Turn on strict standards to see:
You should not expect your second example to work at all. The fact that it does seems to be a coincidence, though PHP does document it.