Why do the 2 addition operations of PHP have a 3 result?
$a = 1;
$c = $a + $a + +;
Var_dump ($c); Result:3
$a = 1;
$c = $a + $a + $a + +;
Var_dump ($c); Result:3
My understanding: The first result should be 2, the second result should be 3
Print output:
int 3
int 3
Share to:
------Solution--------------------
According to the syntax of PHP, your understanding is correct
and the actual result is not the case, so you can think that this is a PHP bug
Just this bug might be intentional, because that's what C is about.
------Solution--------------------
How to find a good number of posts to discuss this issue.
Wikipedia:
In computer programming, undefined behavior (English: Undefined behavior) refers to a computer code that behaves unpredictable. This is a feature of some programming languages, the most famous is in the C language. [1] In these languages, in order to simplify the standard and give a certain degree of flexibility, the standard specifically specifies that the results of certain operations are undefined, which means that the programmer cannot predict what will happen.