RE: [PHP] if/elseif being treated as if/if
| From: | Jay Blanchard | Date: | Fri, 24 Sep 2010 18:25:16 +0000 |
| Subject: | RE: [PHP] if/elseif being treated as if/if | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-308295@lists.php.net to get a copy of this message | ||
[snip]
I am not in the majority when I say for conditions where you have
more than two options use a switch control and not an elseif.
In 40+ years of programming, I have never used elseif because the
control confuses me. It is *much* easier for me to use, understand,
and document a switch statement than an elseif.
[/snip]
I second this, but first I must ask; have you echo'd out the values of
each item to confirm what you are evaluating?
Don't get me wrong, using elseif is a fine control structure if it sees
limited use, like this;
if('foo' == $a){
// do foo
} elseif('bar' == $a){
// do bar
} else {
// do glorp
}
If it goes beyond that I use a switch control and it has served me well
for years.
My bet is if you echo out the values of the items you're evaluating you
will see something that will point you to the cause of your issues.