The C specification (and C++, I believe) state that this the result is undefined. So the compiler can produce any result and still be "correct". I've never seen the spec for PHP, assuming there is one.
R
Ray Kelm
@Ray Kelm
Posts
-
Fun with Operators -
Missing '=' in if-statementbeg to differ, but C and C++ do not evaluate assignments to true. They evaluate to the rvalue. And yes, I just tried it using GCC.
#include int x; int main() { if (x=0) { printf("assignments evaluate to true!\n"); } return 0; }