Computers |
|
| | #1 (permalink) |
| Newb Techie Join Date: Apr 2006
Posts: 10
| I have a problem with following php-code: Code: <? if ($a == 1)
echo "a";
if ($a == 0) {
echo "";
} else {
echo "b";
}
?> When "$a = 1" , it shows "ab". When "$a = 2" or above it shows "b". What am I doing wrong, why does it show "ab", when "$a=1" Hoping for soon answers Regards Beosound |
| | |
| | #2 (permalink) |
| Dope Tech | if a = 1 it displays a then it evaluates the second if else so since a is not 0, it echo's b to prevent b from being displayed, put a else after echo a. Code: <? if ($a == 1)
echo "a";
else {
if ($a == 0)
echo "";
else
echo "b";
}
?>
__________________ Tech IMO.com | ExtremeTech.com | ASP Free.com | SysOpt.com | Tech Support Guy.org DB Forums.com | Cyber Tech Help.com | Lazy Forums.com | Warrior Nation.net 'If you don't stand for somethin you'll fall for anything' - Dr. Dre Been there, done that |
| | |
| | #3 (permalink) | |
| Newb Techie Join Date: Apr 2006
Posts: 10
| Quote:
| |
| | |