Re: switch case - to require the break statements seems strange to me
| From: | Ashley Sheridan | Date: | Fri, 12 Sep 2008 23:29:57 +0000 |
| Subject: | Re: switch case - to require the break statements seems strange to me | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280056@lists.php.net to get a copy of this message | ||
Well, I've often found the need to treat several conditions with the
same set of statements within a switch:
switch($some_number)
{
case 1:
case 2:
{
// do some shizzle
break;
}
case 3:
{
// foshizzle that nizzle
break;
}
default:
{
// dizzle everything else here
}
}
You never need a break in the last case, and you don't need a default
case if you know all the values you expect, although if you do have one,
I believe it does have to be the last statement.
Ash
www.ashleysheridan.co.uk