note 93450 added to control-structures.switch

From: Date: Thu, 10 Sep 2009 14:18:46 +0000
Subject: note 93450 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-160410@lists.php.net to get a copy of this message
varnavruz I don't think you'll ever get 'That's slooooow' because >10 is also >1 and it will encounter a break. You should reverse your cases (and you can use a default): switch ($totaltime) { case ($totaltime > 10): echo "That's slooooow"; break; case ($totaltime > 1): echo "Not fast!"; break; default: echo "That was fast!"; break; } The only thing I noted was that 0 evaluates to bigger than 10 (or even > 9999999999)! ---- Server IP: 64.71.164.2 Probable Submitter: 194.78.35.10 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/93450 Del: integrated -- https://master.php.net/note/delete/93450/integrated Del: useless -- https://master.php.net/note/delete/93450/useless Del: bad code -- https://master.php.net/note/delete/93450/bad+code Del: spam -- https://master.php.net/note/delete/93450/spam Del: non-english -- https://master.php.net/note/delete/93450/non-english Del: in docs -- https://master.php.net/note/delete/93450/in+docs Del: other reasons-- https://master.php.net/note/delete/93450 Reject -- https://master.php.net/note/reject/93450 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160410) next »