Strange questions about PHP values and citations
PHP Code
$a = 1; $b = & $a; $b = $a ++;echo $b. "
"; Echo $a;
Who can tell me what the last $ A and $b results are and why is this result?
------Solution--------------------
I think it's strange: Why do you always have to digest bugs yourself?
This has been a problem for many years, but no one has ever reported this bug
Analysis of specific reasons need to look at the source, but it is too difficult to locate the
by syntax $a + + is equivalent to $a = $a + 1
So
$b = $a + +;
Equivalent to
$b = $a;
$a = $a + 1;
If there are no previous references
$b = & $a;
echo $a;
Is can get the right result 2 of the
As a result of the reference, the rules changed. This is obviously wrong!
This is a bug when implementing a reference in PHP
Of course, he may also be aware of the problem, but can not solve
In short, because of this bug, you try not to explicitly use the reference