Simple logic but can't get it right

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

 



Hi gurus,

 

I've the following piece of PHP code....It is a simple logic but I can't
get it right....The output result of $id is "b"!!...It should be
"outside", right??

 

I think it is the variable $b....Coz' it depend on the previous check (
if ($a == 0) ) for the value... If this is the case, how can I get this
logic works??

 

Thanks a million,

Choy

 

 

 

 

<?php

 

            $a = 1;

            $id = "outside";

            

            if ($a == 0) {

                  

                        $b = 1;

                        $id = "a";

                  

            }

 

 

            elseif ($b == 0) {

                  

                        $c = 1;

                        $id = "b";

                  

            }

 

 

            elseif ($c == 0){

                  

                        $d = 1;

                        $id = "c";

                  

            }

 

            

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

 

 

 

?>


[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