note 113575 added to control-structures.switch

From: Date: Thu, 31 Oct 2013 14:30:17 +0000
Subject: note 113575 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-197362@lists.php.net to get a copy of this message
Some interesting stuff. // 0-99: OK // Other: ERROR $codigo = (int) '000'; // Results: ERROR switch( $codigo ) { case( $codigo >= 0 AND $codigo < 100 ): echo 'OK'; break; default: echo 'ERROR'; break; } // Results: OK switch( $codigo ) { case 0: case( $codigo > 0 AND $codigo < 100 ): echo 'OK'; break; default: echo 'ERROR'; break; } There's something tricky on how the case deals with the zero evaluation. ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/113575 Del: integrated -- https://master.php.net/note/delete/113575/integrated Del: useless -- https://master.php.net/note/delete/113575/useless Del: bad code -- https://master.php.net/note/delete/113575/bad+code Del: spam -- https://master.php.net/note/delete/113575/spam Del: non-english -- https://master.php.net/note/delete/113575/non-english Del: in docs -- https://master.php.net/note/delete/113575/in+docs Del: other reasons-- https://master.php.net/note/delete/113575 Reject -- https://master.php.net/note/reject/113575 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197362) next »