Re: Which is quicker, if-else statements
| From: | Kevin Stone | Date: | Tue, 18 Mar 2003 20:09:28 +0000 |
| Subject: | Re: Which is quicker, if-else statements | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140179@lists.php.net to get a copy of this message | ||
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
----- Original Message -----
From: "Liam Gibbs" <liamgibbs@sympatico.ca>
To: "php list" <php-general@lists.php.net>
Sent: Tuesday, March 18, 2003 1:02 PM
Subject: [PHP] Which is quicker, if-else statements
Is it just as quick to do:
if($r == 0) {
} else if($r != 0) {
}
than to do:
if($r == 0) {
} else {
}
The reason I like the former method is because, in a large IF-ELSE block,
it's clear what belongs to what IF and what's going on. But does this make
it lag? And, if so, is it really all that noticeable?