operator strange behaviour

From: Date: Sat, 30 Oct 2004 18:45:07 +0000
Subject: operator strange behaviour
Groups: php.internals 
Request: Send a blank email to internals+get-13634@lists.php.net to get a copy of this message
Hi! I tried to get answer on the general list, but I didn't get. I have a little example, which generate strange output. $a = 0; $b = 1; if ($a = 1 && $b = 0) {
    echo 'true ';
    var_dump($a);
    var_dump($b);
} else {
    echo 'false ';
    var_dump($a);
    var_dump($b);
} Runing this we get: "flase bool(false) int(0)" After the precedence table the first step should be evaluating the &&, and we get something like this: $a = false = 0, which should generate an error, while there isn't an "lvalue" on the left side of the =. But doesn't this happen. It seems, that the evaluation of the first = came before evaluating the &&. Can someone exactly explain how PHP process this condition? THX in advance, Felho

« previous php.internals (#13634) next »