Bluehost.com Web Hosting $6.95

if else VS switch

This is a discussion on if else VS switch within the PHP Language forums, part of the PHP Programming Forums category; Hi, The behavior between if else and switch is not different in PHP. However is there difference for the performance (...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-01-2006
Don
 
Posts: n/a
Default if else VS switch

Hi,

The behavior between if else and switch is not different in PHP.
However is there difference for the performance (I know in C it's
different) while interpreting the script?

Thanks in advance

Don
Reply With Quote
  #2 (permalink)  
Old 05-01-2006
Good Man
 
Posts: n/a
Default Re: if else VS switch

Don <NOSPAMdon.h@free.fr> wrote in news:44561ee5$0$14027
$626a54ce@news.free.fr:

> Hi,
>
> The behavior between if else and switch is not different in PHP.
> However is there difference for the performance (I know in C it's
> different) while interpreting the script?
>
> Thanks in advance


if i recall correctly, one of the bugfixes/improvements to the
latest/greatest PHP version was improving the speed of switch statements...
so I assume they are as fast as if/else at least right now...

obviously the real benefit of using 'switch' is that its great for going
through many possible conditions, and results in far more readable code.
Reply With Quote
  #3 (permalink)  
Old 05-02-2006
Schraalhans Keukenmeester
 
Posts: n/a
Default Re: if else VS switch

Don wrote:
> Hi,
>
> The behavior between if else and switch is not different in PHP.
> However is there difference for the performance (I know in C it's
> different) while interpreting the script?
>
> Thanks in advance
>
> Don

Why don't you test it ? using microtime() this should be a piece of cake.

Which one should be faster in C according to your data?
Sh.

--
Sigh. I like to think it's just the Linux people who want to be on
the "leading edge" so bad they walk right off the precipice.
(Craig E. Groeschel)
Reply With Quote
  #4 (permalink)  
Old 05-06-2006
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: if else VS switch

Don wrote:
> Hi,
>
> The behavior between if else and switch is not different in PHP.
> However is there difference for the performance (I know in C it's
> different) while interpreting the script?


IIRC, switch is based on look up tables and might be faster.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:46 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0