Re: Simple logic but can't get it right

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



comments inline

Choy, Wai Yew wrote:
<?php
$a = 1;

            $id = "outside";

this if statement is false, because $a == 1
if ($a == 0) {
                        $b = 1;

                        $id = "a";

            }

this if statement is true, because $b has not been defined, and is evaluating to 0
            elseif ($b == 0) {

                        $c = 1;

$id = "b";

            }

this statement never gets reached, because the previous statement was true
            elseif ($c == 0){

                        $d = 1;

                        $id = "c";

            }

 echo "ID = $id<br>"; //Output is "b"...WHY?? It should be "outside"...

?>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux