Re: switch vs elseif
| From: | Eric Butera | Date: | Mon, 12 Jan 2009 20:56:32 +0000 |
| Subject: | Re: switch vs elseif | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286146@lists.php.net to get a copy of this message | ||
On Mon, Jan 12, 2009 at 3:58 PM, Frank Stanovcak
<blindspotpro@comcast.net> wrote:
>
> ""Eric Butera"" <eric.butera@gmail.com> wrote in message
>
> news:6a8639eb0901121231r253eed48xe1974d8ef44ab95e@mail.gmail.com...
>> On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak
>> <blindspotpro@comcast.net> wrote:
>>> I've googled, and found some confusing answers.
>>> I've tried searching the history of the news group, and only found info
>>> on
>>> switch or elseif seperately. :(
>>>
>>> Strictly from a performance stand point, not preference or anything else,
>>> is
>>> there a benefit of one over the other?
>>>
>>>
>>> for($i=0;$i<3;$i++){
>>> switch($i){
>>> case 0:
>>> header pg1 code
>>> break;
>>> case 1:
>>> header pg2 code
>>> break;
>>> case 3:
>>> header pg3 code
>>> break;
>>> };
>>> };
>>>
>>>
>>> or would that be better served using an if...elseif structure?
>>>
>>> Frank
>>>
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> This might be of interest in answering your question:
>>
>> http://www.suspekt.org/switchtable/
>
> Wow...so if I read that right. the only difference in the root code of PHP
> is that the pre compiled code is easier to read. PHP actually generates the
> If...elseif...elseif... structure any way when it compiles the script.
>
> ewww.
>
> Frank.
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Yea I was bummed out to hear that too because I had heard switch was
faster. Oh well. :)