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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to