note 91820 added to control-structures.switch

From: Date: Fri, 26 Jun 2009 16:28:15 +0000
Subject: note 91820 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-157551@lists.php.net to get a copy of this message
PHP must improve the switch statement. I think it's dumb and a great performance offense to put a switch($value) then a case ($value == 1||$value = ...). If you really need these kind of comparisons, use the good and old if statement. Something really annoying is the "break" in every case in the switch. The comparison I've said and "break" must be abolished with the adoption of inline comparisons, like in VB - sorry about saying that, but it's select is much better - Something like this: switch ($value) { case 1: echo "Value is 1!"; case (2, 3, 4, 5): echo "Value is between 2 and 5!"; // or case (2||3||4||5)... } See that? Just direct and no redundant comparisons relatively to what we want to compare, $value at the argument of the statement. Cheers. ---- Server IP: 187.16.23.134 Probable Submitter: 189.19.66.246 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/91820 Del: integrated -- https://master.php.net/note/delete/91820/integrated Del: useless -- https://master.php.net/note/delete/91820/useless Del: bad code -- https://master.php.net/note/delete/91820/bad+code Del: spam -- https://master.php.net/note/delete/91820/spam Del: non-english -- https://master.php.net/note/delete/91820/non-english Del: in docs -- https://master.php.net/note/delete/91820/in+docs Del: other reasons-- https://master.php.net/note/delete/91820 Reject -- https://master.php.net/note/reject/91820 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157551) next »