note 65307 added to control-structures.switch

From: Date: Fri, 28 Apr 2006 14:04:43 +0000
Subject: note 65307 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-109982@lists.php.net to get a copy of this message
In response to mark at softmedia4u dot com: This example is using bare words instead of strings, so while a is converted into the string 'a', b-a is converted into 'b'-'a' at which point the strings are converted to numbers (0) and the whole thing ends up reading 'case 0'. If you compare a string with 0 that doesn't start with digits, you always get a match, so this is, in fact, not behaviour equivalent to 'default'. You probably want to use case 'b-a'. ---- Server IP: 212.124.37.9 Probable Submitter: 87.78.90.9 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- http://master.php.net/note/edit/65307 Del: integrated -- http://master.php.net/note/delete/65307/integrated Del: useless -- http://master.php.net/note/delete/65307/useless Del: bad code -- http://master.php.net/note/delete/65307/bad+code Del: spam -- http://master.php.net/note/delete/65307/spam Del: non-english -- http://master.php.net/note/delete/65307/non-english Del: in docs -- http://master.php.net/note/delete/65307/in+docs Del: other reasons-- http://master.php.net/note/delete/65307 Reject -- http://master.php.net/note/reject/65307 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#109982) next »