On Fri, 2010-09-24 at 15:54 -0400, Bob McConnell wrote: > 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 > I don't often use this type of logic, but I have used it before and it's served me well. Essentially, a switch is a glorified if statement, and I find them a lot nicer to read and write than a series of if/elseif blocks. Thanks, Ash http://www.ashleysheridan.co.uk