note 34886 added to control-structures.switch
| From: | (cgibbard) | Date: | Sun, 10 Aug 2003 07:30:30 +0000 |
| Subject: | note 34886 added to control-structures.switch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53804@lists.php.net to get a copy of this message | ||
Just in reply to the comment about 2 digit numbers: something octal certainly is going on. Integer
literals prefixed with a "0", like in C and several other languages, are treated as octal.
Similarly, integer literals prefixed with "0x" are treated as hexadecimal. Seeing as this
is the case, 08 and 09 are not valid integer literals. It turns out that php treats them as 0 (it
would probably be better to fail with an error message, but it doesn't). Bottom line?
Don't prefix numbers with 0 in code unless you mean octal. Format them as you print them with
printf, like so: printf("%02u", $my_unsigned_int); or if you will, use sprintf to get a
string representation rather than printing on stdout.
----
Manual Page -- http://www.php.net/manual/en/control-structures.switch.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34886
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34886&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34886&report=yes