note 102244 added to control-structures.switch

From: Date: Thu, 03 Feb 2011 17:57:53 +0000
Subject: note 102244 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-176653@lists.php.net to get a copy of this message
theimp at iinet dot net dot au : How is that mess better than the sane way of doing it? <?php function flavor($type = null) { $flavors = array('chocolate', 'strawberry', 'vanilla'); if (in_array($type, $flavors)) { return "Flavor selected: $type"; } else { return "Flavors available: " . implode(", ", $flavors); } } ?> I'm all for learning the ins and outs of the PHP interpreter, but you're trying to say that your abuse of the switch syntax will somehow cut down on code maintenance? How can that be, when your method requires copy-pasting code (always a red flag) and the normal way doesn't? ---- Server IP: 69.147.83.197 Probable Submitter: 12.239.150.194 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/102244 Del: integrated -- https://master.php.net/note/delete/102244/integrated Del: useless -- https://master.php.net/note/delete/102244/useless Del: bad code -- https://master.php.net/note/delete/102244/bad+code Del: spam -- https://master.php.net/note/delete/102244/spam Del: non-english -- https://master.php.net/note/delete/102244/non-english Del: in docs -- https://master.php.net/note/delete/102244/in+docs Del: other reasons-- https://master.php.net/note/delete/102244 Reject -- https://master.php.net/note/reject/102244 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#176653) next »