Re: Question about using if elseif ...
| From: | Pete James | Date: | Thu, 18 Jul 2002 21:56:01 +0000 |
| Subject: | Re: Question about using if elseif ... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108343@lists.php.net to get a copy of this message | ||
>
> Is there any problem with leaving out the last else and just ending it with
> an elseif such as ...
>
> if($a == '1'){
> echo '1';
> } elseif ($a == '2'){
> echo '2';
> }
Nothing syntactically, but surely you wouldn't want a rogue '3' or '0'
to fall through the cracks... that wouldn't be very good, and depending
on the circumstances, could be a serious breach of security. And it
_will_ happen one day if you get in the habit of not using else _all the
time_.
P.