+ 4
Why php displays here wrong result?
4 odpowiedzi
+ 4
KrOW thanks, so left side associative is in php, does that mean that in JavaScript is different? Surely it is different, because result there is 1 as it should be - right side or? For me this is confusing beyond understanding. I have to admit that Ive had similar situations in my php code that I have to resolve by using explicit parenthesis.
+ 2
Im not sure but i think that before is valued the first ternary operator which result is used in the second... In practice:
true ? 1 : false? 2:3
its like
((true ? 1 : false)? 2:3)
then :
((1)?2:3 == 2
+ 1
Just now i readed than ternary operator is left-side associative then, its like i said
+ 1
de do Yes... Php use left-to-right associativity for ternary, js use right-to left makin previous expression valued like:
(true? 1:(false? 2:3))