note 63592 deleted from control-structures.switch by bjori

From: Date: Fri, 24 Mar 2006 19:33:34 +0000
Subject: note 63592 deleted from control-structures.switch by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106545@lists.php.net to get a copy of this message
Note Submitter: Reason: useless ---- 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 */

« previous php.notes (#106545) next »