smolalmonse
New Member
I love getting myself into these ridiculous situations where I over-evaluate my coding practices, so here goes!This question probably transcends PHP (as well as sanity). When evaluating a Boolean variable, which of these is best practice? (assume that there's too much \[code\]//do stuff\[/code\] for a ternary)\[code\]if ($bool) { // do true stuff} else { // do false stuff}\[/code\]or\[code\]switch ($bool) { case true: // do true stuff break; default: // do false stuff break;}\[/code\]I'm interested more in performance and/or idiosyncratic considerations than blanket statements like "If/Else looks better," "Always use Switch," or "Do what you feel is right."That is, unless there really isn't a difference.