I ++ int & nbsp; I & nbsp; 3; I & nbsp; + & nbsp; I ++ & nbsp; + & nbsp; ++ I; the above code outputs 11 in JavaC # JavaScript, but 12 in PHP. what is the difference between PHP computing and other three? Think Twice. please give me some advice! -I ++ problems
Int I = 3;
I = I + I ++ I;
The above code outputs 11 in both Java/C #/JavaScript, but 12 in PHP. what is the difference between PHP computing and three for him? Think Twice. please give me some advice!
------ Solution --------------------
$ I = 3;
$ A = $ I + $ I ++ $ I;
Echo $ a; // 12
This is a php BUG.
It seems that all php5 has this problem (at least three versions at hand)
The problem lies in the first $ I value transfer method, such as writing
$ I = 3;
$ A = ($ d = $ I) + $ I ++ $ I;
Echo $ a; // 11
That's correct.
Obviously, the first $ I is passed as a reference, because the following $ I ++ is actually involved in the operation of 4 rather than 3
Remove ++ $ I to make it clearer.