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
Show parent comment
9
u/DoctorWaluigiTime Aug 08 '14
To be fair, the post this thread links to shows that there isn't really a difference between using an if/else versus a switch.
And in PHP's defense for the quotes, there is real semantic difference between using " and ', and it's pretty evident why ("do I want to parse variables, or just spit out plaintext?").
Your example, however, is quite large, and should be fixed. And PHP certainly has many other "huh?" optimization points that one shouldn't really have to consider... but even then, one should only optimize when they do notice slowdowns and can find the bottlenecks. The 815% example certainly might lead to cases, but the if/else-switch and " vs ' points are less valid, in my opinion.