Re: Which is quicker, if-else statements
| From: | Robert Cummings | Date: | Tue, 18 Mar 2003 20:57:16 +0000 |
| Subject: | Re: Which is quicker, if-else statements | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140192@lists.php.net to get a copy of this message | ||
Kevin Stone wrote:
>
> Logically the if-else construct is faster becuase PHP doesn't have to parse
> and execute the second conditional. An if-elseif construct is ussually
> followed by an else block to describe a default action if no other
> conditions are true. Otherwise you may as well use sequential if()
> statements becuase it's exactly the same thing.
> - Kevin
Sequential if() statments will not be the same as the if-elseif() system
when more than two conditional checks are matched. The sequential will
process both blocks, whereas the if-elseif() will only process the first
match :)
Cheers,
Rob.
--
.---------------------------------------------.
| Worlds of Carnage - http://www.wocmud.org |
:---------------------------------------------:
| Come visit a world of myth and legend where |
| fantastical creatures come to life and the |
| stuff of nightmares grasp for your soul. |
`---------------------------------------------'