note 63592 added to control-structures.switch

From: Date: Fri, 24 Mar 2006 18:18:25 +0000
Subject: note 63592 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-106539@lists.php.net to get a copy of this message
fg at NOSPAM dot puertodelacruz dot org at 21-Mar-2006 02:16 wrote: > Use of break after return. > It may be obvious, but many user samples insist exposing unreachable code. > If you use return, subsequent code will not be executed. So break > statements are not needed. > $a=1; > echo foo($a); > function foo($a){ > switch($a){ > case 1: > return 'Desperate value returned!'; > $retval='One'; > break; fallthrough is a bit tricky, so i'd insist on marking it in some way. the standard practice is doing it that way: function foo($a){ switch($a){ case 1: return 'Desperate value returned!'; /* NOTREACHED */ ---- Server IP: 81.223.254.68 Probable Submitter: 85.221.230.102 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- http://master.php.net/note/edit/63592 Del: integrated -- http://master.php.net/note/delete/63592/integrated Del: useless -- http://master.php.net/note/delete/63592/useless Del: bad code -- http://master.php.net/note/delete/63592/bad+code Del: spam -- http://master.php.net/note/delete/63592/spam Del: non-english -- http://master.php.net/note/delete/63592/non-english Del: in docs -- http://master.php.net/note/delete/63592/in+docs Del: other reasons-- http://master.php.net/note/delete/63592 Reject -- http://master.php.net/note/reject/63592 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106539) next »