[Advice] Why are the results of the two addition operations of PHP three?
In my understanding, the first result should be 2, and the second result should be 3.
Print output:
int 3int 3
Reply to discussion (solution)According to the php syntax, your understanding is correct.
The actual running result is not like this, so you can think that this is a php bug.
This bug may also be intended because it is the same in C language.
According to the php syntax, your understanding is correct.
The actual running result is not like this, so you can think that this is a php bug.
This bug may also be intended because it is the same in C language.
Thank you! I have read the post you have replied to before posting http://bbs.csdn.net/topics/390571704, but I still do not understand it, so I sent it again. thank you ~~
According to the php syntax, your understanding is correct.
The actual running result is not like this, so you can think that this is a php bug.
This bug may also be intended because it is the same in C language.
It does not seem like this in moderator C:
#include
int main() { int a = 1; printf("a=%d\n",a+a++); a = 1; printf("a=%d\n",a+a+a++); return 0;}
Output:
a=2a=3
This is C ++. I am talking about C.
According to the php syntax, your understanding is correct.
The actual running result is not like this, so you can think that this is a php bug.
This bug may also be intended because it is the same in C language.
It does not seem like this in moderator C:
#include
int main() { int a = 1; printf("a=%d\n",a+a++); a = 1; printf("a=%d\n",a+a+a++); return 0;}
Output:
a=2a=3
Strange .. I am not a C ++ either. How can I find many posts discussing this problem.
Wikipedia:
In computer programming, Undefined behavior refers to computer code with unpredictable behavior. This is a feature of some programming languages. The most famous is in C language. [1] In these languages, in order to simplify the standards and provide some flexibility, the standards specifically stipulate that the results of some operations are undefined, this means that programmers cannot predict what will happen.
How can I find many posts discussing this problem.
Wikipedia:
In computer programming, Undefined behavior refers to computer code with unpredictable behavior. This is a feature of some programming languages. The most famous is in C language. [1] In these languages, in order to simplify the standards and provide some flexibility, the standards specifically stipulate that the results of some operations are undefined, this means that programmers cannot predict what will happen.
I learned a lot again. thank you !!!