note 60226 added to control-structures.break

From: Date: Fri, 30 Dec 2005 14:53:52 +0000
Subject: note 60226 added to control-structures.break
Groups: php.notes 
Request: Send a blank email to php-notes+get-100992@lists.php.net to get a copy of this message
vlad at vlad dot neosurge dot net wrote on 04-Jan-2003 04:21 > Just an insignificant side not: Like in C/C++, it's not > necessary to break out of the default part of a switch > statement in PHP. It's not necessary to break out of any case of a switch statement in PHP, but if you want only one case to be executed, you have do break out of it (even out of the default case). Consider this: <?php $a = 'Apple'; switch ($a) { default: echo '$a is not an orange<br>'; case 'Orange': echo '$a is an orange'; } ?> This prints (in PHP 5.0.4 on MS-Windows): $a is not an orange $a is an orange Note that the PHP documentation does not state the default part must be the last case statement. ---- Manual Page -- http://www.php.net/manual/en/control-structures.break.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60226 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60226&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60226&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100992) next »