Re: php compiler

From: Date: Sat, 30 Oct 2004 14:00:28 +0000
Subject: Re: php compiler
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200713@lists.php.net to get a copy of this message
Hodicska Gergely wrote:
$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: "true bool(false) int(0)"
Are you sure you posted the example correctly? It outputs this: false bool(false) int(0) And this output is absolutely correct. Your condition gives new values to $a and $b because you use "=" and not "==". So you do this: $b = 0; $a = 1 && $b; The condition checks the value of $a (which is false) and so you land in the else branch and that's why $b is int(0) and $a is bool(false) I think you want this: if ($a == 1 && $b == 0) -- Bye, K <http://www.ailis.de/~k/> (FidoNet: 2:240/2188.18) [A735 47EC D87B 1F15 C1E9 53D3 AA03 6173 A723 E391] (Finger k@ailis.de to get public key)

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.general (#200713) next »