RE: [PHP] if/elseif being treated as if/if

From: Date: Fri, 24 Sep 2010 19:54:43 +0000
Subject: RE: [PHP] if/elseif being treated as if/if
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-308302@lists.php.net to get a copy of this message
From: tedd > At 2:23 PM -0400 9/24/10, Bob McConnell wrote: >> >>A switch works when a single test can dispatch all possible branches. If >>you have a series of tests where each looks for a different subset of >>conditions, you need an elseif. > Not so, O'wise one. > > This will work: > > switch(1) > { > case $a > $b: > /* whatever > break; > > case $c == 1: > /* whatever > break; > > case $d == 'this works': > /* whatever > break; > } > > Granted, it's not the normal way a switch works in some other > languages, but it does work in PHP. :-) That is just so wrong, it can't actually be taken seriously. There is simply no justification for such broken logic. Bob McConnell

« previous php.general (#308302) next »