+ 1
PHP issue
Please, explain the difference of the results of the code. The essence of the examples is the same, the recording is different and for some reason different results. https://code.sololearn.com/wdW992lqkxG9/?ref=app
2 Réponses
+ 1
You missed the parenthesis in the part with b.
In the one with a, you are performing the arithmetic on the right side of the += operator and THEN add to value of a.
In the second one to have same effect, you need to perform the required arithmetic first (by using parenthesis - parenthesis are high priority), and then add to value of b.
I added the editted code. Hope it helps.
https://code.sololearn.com/w1agm7F2sV3Z/?ref=app
0
Thank you for the answer
But can you explain, why result in my 2nd example is 6