note 57668 added to control-structures.switch

From: Date: Mon, 10 Oct 2005 22:55:18 +0000
Subject: note 57668 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-96798@lists.php.net to get a copy of this message
<?php //Depending on Group switch (TRUE) { //[snip] case in_array('rma_rma', $userGroup): $home = "rma_home.php"; break; } ?> -- Folks, these switch(TRUE) statements are totally useless and in many cases incomprehensible to those of us inheriting projects written by bad coders! That's basically replicating the functionality of an if..then statement. Observe: <?php if ( in_array('rma_rma',$userGroup) ) { $home="rma_home.php"; } ?> I've taken essentially a 5 line switch statement and brought it down to a 3-line if statement, and it's more readable. Heck, why wouldn't "groupHome" be a seperate variable, or database entry thereby eliminating that whole statement anyway? ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57668 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57668&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57668&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96798) next »