note 76591 added to control-structures.switch

From: Date: Sat, 21 Jul 2007 19:00:35 +0000
Subject: note 76591 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-128796@lists.php.net to get a copy of this message
In response to 'i luv spam', when you enter 07, you tell PHP to interpret a number as an octal number (much like '0x' for hex numbers). Octal numbering system uses only 8 digits, i.e. 0-7. http://en.wikipedia.org/wiki/Octal The number 8 does not exist in octal numbering system. The comparison works because the octal numbers 0 to 7 have identical counterparts in decimal system. So, in order to get a number compared as decimal 8, you would have to enter 010 in the case. BTW this behavior obviously isn't specific to switch, it's a part of PHP. (I personally stumbled into this when trying to make my code nicely indented while declaring an array) ---- Server IP: 193.198.184.18 Probable Submitter: 193.198.152.91 ---- Manual Page -- http://www.php.net/manual/en/control-structures.switch.php Edit -- https://master.php.net/note/edit/76591 Del: integrated -- https://master.php.net/note/delete/76591/integrated Del: useless -- https://master.php.net/note/delete/76591/useless Del: bad code -- https://master.php.net/note/delete/76591/bad+code Del: spam -- https://master.php.net/note/delete/76591/spam Del: non-english -- https://master.php.net/note/delete/76591/non-english Del: in docs -- https://master.php.net/note/delete/76591/in+docs Del: other reasons-- https://master.php.net/note/delete/76591 Reject -- https://master.php.net/note/reject/76591 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128796) next »