note 91820 rejected from control-structures.switch by danbrown

From: Date: Fri, 26 Jun 2009 16:38:25 +0000
Subject: note 91820 rejected from control-structures.switch by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157552@lists.php.net to get a copy of this message
Note Submitter: mendelsongusmao at gmail dot com ---- 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.

« previous php.notes (#157552) next »