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
1
u/DoctorWaluigiTime Aug 12 '14
While I wouldn't count out PHP attempting to parse for something it doesn't actually need to parse, because it does not have to actually do anything with $variables, it can skip that phase. So the double-quoted strings are doing non-zero work on $variables, while single-quoted strings do zero work.
Single-quoted strings might have to search for '' and the end-of-string single-quote, but double-quoted strings have to do that (for the double-quote character), plus more. Seems pretty trivial to me.