Re: switch case - to require the break statements seems strange to me
| From: | Robert Cummings | Date: | Fri, 12 Sep 2008 16:12:54 +0000 |
| Subject: | Re: switch case - to require the break statements seems strange to me | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280015@lists.php.net to get a copy of this message | ||
On Fri, 2008-09-12 at 10:58 +0100, Luke wrote:
> I wonder if this is a shared trait between C and PHP (since I understand PHP
> is written in C) that the break; and the default: are placed for good
> practice in all switch statements since they prevent memory leaks?
Prevent memory leaks? WHAT?
Even if that were an issue, implementation of switch in PHP does not
look like a switch.
Breaks are used to prevent fall through to the next case condition.
Default is used as a catch-all... if you need a catch-all. It is
perfectly valid for a case statement to fall through to the next case
statement if the code can be shared.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP