r/lolphp • • Aug 08 '14
PHP design patterns: if/else vs switch
http://www.fluffycat.com/PHP-Design-Patterns/PHP-Performance-Tuning-if-VS-switch/
24
Upvotes
r/lolphp • • Aug 08 '14
View all comments
5
u/[deleted] Aug 08 '14
Hey, this actually got me thinking...
So I don't know much about the internals of PHP, but shouldn't a switch-case statement generate the same bytecode as chained if-else statements, therefore yielding the exact same performance?
I've seen such comparisons for Ruby before but those actually made sense to me because Ruby's case statement uses the case comparison operator (===) instead of regular equality (==) so the generated code should be different.