PHPcode $ a = 1; $ B = & amp; $ a; $ B = $ a ++; echo $ B. & quot; & lt; br/& gt; & quot; echo $; who can tell me the last result of $ a and $ B? what are the strange questions about PHP value passing and reference passing?
PHP code
$ A = 1; $ B = & $ a; $ B = $ a ++; echo $ B ."
"; Echo $;
Who can tell me what the final result of $ a and $ B is and why?
------ Solution --------------------
I think the strange thing is: why always digest bugs by yourself?
This problem has been around for many years, but no one has ever reported this bug.
To analyze the specific cause, you need to look at the source code, but it is too difficult to locate it.
According to the syntax, $ a ++ is equivalent to $ a = $ a + 1.
That is to say
$ B = $ a ++;
Equivalent
$ B = $;
$ A = $ a + 1;
If there is no previous reference
$ B = & $;
Echo $;
Yes. expected result 2 is displayed.
With the reference, the rule changes. This is obviously wrong!
This is a bug in php implementation reference.
Of course, he may be aware of the problem but cannot solve it.
In short, because of the existence of this bug, you should try not to explicitly use the reference