Re: [PHP] switch vs elseif

2009-01-14 Thread tedd
At 2:18 PM -0600 1/13/09, Micah Gersten wrote: Jochem Maas wrote: switch (true) { case ($x === $y): // something break; This is a misuse of the switch statement. Switch is meant to compare values to a single variable as stated on the manual page:

Re: [PHP] switch vs elseif

2009-01-13 Thread Jochem Maas
Ashley Sheridan schreef: On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not

Re: [PHP] switch vs elseif

2009-01-13 Thread Eric Butera
On Tue, Jan 13, 2009 at 9:50 AM, Jochem Maas joc...@iamjochem.com wrote: switch (true) { case ($x === $y): // something break; case ($a != $b): // something break; case (myFunc()): //

Re: [PHP] switch vs elseif

2009-01-13 Thread Robert Cummings
On Tue, 2009-01-13 at 15:50 +0100, Jochem Maas wrote: Ashley Sheridan schreef: On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately.

Re: [PHP] switch vs elseif

2009-01-13 Thread Micah Gersten
Jochem Maas wrote: switch (true) { case ($x === $y): // something break; case ($a != $b): // something break; case (myFunc()): // something break; case

Re: [PHP] switch vs elseif

2009-01-13 Thread ceo
I think if they didn't want us to use expressions in the case, then they wouldn't have put support into the language for that. I daresay you are reading more into the text than was intended... I certainly have found switch(true) with complex expressions for case quite handy and very clear

Re: [PHP] switch vs elseif

2009-01-13 Thread Jochem Maas
Micah Gersten schreef: Jochem Maas wrote: switch (true) { case ($x === $y): // something break; case ($a != $b): // something break; case (myFunc()): // something break; case

Re: [PHP] switch vs elseif

2009-01-13 Thread Nathan Rixham
Jochem Maas wrote: Micah Gersten schreef: Jochem Maas wrote: switch (true) { should be switch(false) { :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] switch vs elseif

2009-01-13 Thread Jochem Maas
Robert Cummings schreef: On Tue, 2009-01-13 at 15:50 +0100, Jochem Maas wrote: Ashley Sheridan schreef: On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch

Re: [PHP] switch vs elseif

2009-01-13 Thread Jochem Maas
Nathan Rixham schreef: Jochem Maas wrote: Micah Gersten schreef: Jochem Maas wrote: switch (true) { should be switch(false) { :-) it could be either depending on your needs, no? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] switch vs elseif

2009-01-13 Thread Shawn McKenzie
Micah Gersten wrote: Jochem Maas wrote: switch (true) { case ($x === $y): // something break; case ($a != $b): // something break; case (myFunc()): // something break; case

Re: [PHP] switch vs elseif

2009-01-13 Thread Robert Cummings
On Tue, 2009-01-13 at 22:12 +0100, Jochem Maas wrote: Robert Cummings schreef: On Tue, 2009-01-13 at 15:50 +0100, Jochem Maas wrote: Ashley Sheridan schreef: On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching

Re: [PHP] switch vs elseif

2009-01-13 Thread Kirk . Johnson
I regret that I don't recall who made the brilliant observation that programmers spend the majority of their time *reading* code (their own or others) as opposed to *writing* code. So, I make it a point to try to make my code easily scannable. I only and always use the switch construct when

Re: [PHP] switch vs elseif

2009-01-12 Thread Eric Butera
On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference

Re: [PHP] switch vs elseif

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is

Re: [PHP] switch vs elseif

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is

Re: [PHP] switch vs elseif

2009-01-12 Thread Frank Stanovcak
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1231793310.3558.55.ca...@localhost.localdomain... On Mon, 2009-01-12 at 15:15 -0500, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info

Re: [PHP] switch vs elseif

2009-01-12 Thread Frank Stanovcak
Eric Butera eric.but...@gmail.com wrote in message news:6a8639eb0901121231r253eed48xe1974d8ef44ab...@mail.gmail.com... On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news

Re: [PHP] switch vs elseif

2009-01-12 Thread Eric Butera
On Mon, Jan 12, 2009 at 3:58 PM, Frank Stanovcak blindspot...@comcast.net wrote: Eric Butera eric.but...@gmail.com wrote in message news:6a8639eb0901121231r253eed48xe1974d8ef44ab...@mail.gmail.com... On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've

Re: [PHP] switch vs elseif -- switchtable

2009-01-12 Thread Daevid Vincent
On Mon, 2009-01-12 at 15:31 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately.

Re: [PHP] switch vs elseif -- switchtable

2009-01-12 Thread Eric Butera
On Mon, Jan 12, 2009 at 4:00 PM, Daevid Vincent dae...@daevid.com wrote: On Mon, 2009-01-12 at 15:31 -0500, Eric Butera wrote: On Mon, Jan 12, 2009 at 3:15 PM, Frank Stanovcak blindspot...@comcast.net wrote: I've googled, and found some confusing answers. I've tried searching the history

Re: [PHP] switch vs elseif

2009-01-12 Thread tedd
At 3:15 PM -0500 1/12/09, Frank Stanovcak wrote: I've googled, and found some confusing answers. I've tried searching the history of the news group, and only found info on switch or elseif seperately. :( Strictly from a performance stand point, not preference or anything else, is there a

Re: [PHP] switch vs elseif

2009-01-12 Thread tedd
At 3:32 PM -0500 1/12/09, Robert Cummings wrote: One has to wonder about the readability of the case version though since one may not notice immediately the missing break statement. Cheers, Rob. Yes, but that's because of the way you wrote it -- consider this: ?php switch( $foo ) {

Re: [PHP] switch vs elseif

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 16:49 -0500, tedd wrote: At 3:32 PM -0500 1/12/09, Robert Cummings wrote: One has to wonder about the readability of the case version though since one may not notice immediately the missing break statement. Cheers, Rob. Yes, but that's because of the way you wrote

Re: [PHP] switch vs elseif

2009-01-12 Thread Chris
tedd wrote: At 3:32 PM -0500 1/12/09, Robert Cummings wrote: One has to wonder about the readability of the case version though since one may not notice immediately the missing break statement. Cheers, Rob. Yes, but that's because of the way you wrote it -- consider this: I'm sure that was

Re: [PHP] switch vs elseif

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 16:49 -0500, tedd wrote: At 3:32 PM -0500 1/12/09, Robert Cummings wrote: One has to wonder about the readability of the case version though since one may not notice immediately the missing break statement. Cheers, Rob. Yes, but that's because of the way you wrote

Re: [PHP] switch vs elseif

2009-01-12 Thread tedd
At 4:57 PM -0500 1/12/09, Robert Cummings wrote: No, that's DIFFERENT from what I wrote. Go back and re-read. :) I did and reread again -- it looks different. I'm simply talking about the spacing. No matter though, it's the same code. Cheers, tedd -- --- http://sperling.com

Re: [PHP] switch vs elseif

2009-01-12 Thread Robert Cummings
On Mon, 2009-01-12 at 17:09 -0500, tedd wrote: At 4:57 PM -0500 1/12/09, Robert Cummings wrote: No, that's DIFFERENT from what I wrote. Go back and re-read. :) I did and reread again -- it looks different. I'm simply talking about the spacing. No matter though, it's the same code.

Re: [PHP] switch vs elseif

2009-01-12 Thread tedd
At 5:12 PM -0500 1/12/09, Robert Cummings wrote: On Mon, 2009-01-12 at 17:09 -0500, tedd wrote: At 4:57 PM -0500 1/12/09, Robert Cummings wrote: No, that's DIFFERENT from what I wrote. Go back and re-read. :) I did and reread again -- it looks different. I'm simply talking about the