Re: switch vs elseif

From: Date: Wed, 14 Jan 2009 17:07:40 +0000
Subject: Re: switch vs elseif
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-286329@lists.php.net to get a copy of this message
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: http://us2.php.net/switch Thank you, Micah Gersten
Micah: I disagree. You may use a switch statement as Jochem demonstrated -- I do it all the time. Just because you think the value within the switch is supposed to be the value examined doesn't mean that doing it otherwise is wrong -- it's just a different way of using that statement. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#286329) next »