[thelist] php SWITCH vs ELSE IF
Ian Anderson
ian at zstudio.co.uk
Mon Apr 24 08:09:27 CDT 2006
Mark Mckee wrote:
> i am using an ELSE IF statement and would like to know if this would be
> better than using a switch statement.
Well, they are basically equivalent. Switch may be preferable because it
is easier to see what is going on, is slightly faster in some edge
cases, and is generally regarded as more correct style.
I wouldn't go and rewrite existing code to change it over, but if you're
coding something right now, if you have the time I'd say use the
preferred structure from the outset.
hope this helps
Cheers
Ian
--
zStudio - Web development and accessibility
- http://zStudio.co.uk
Snippetz.net - Your personal, private code library
- http://snippetz.net
More information about the thelist
mailing list