In my previous post I asked what would be the output of of the following numbers:
echo 09," => (09) <br>";
echo 9," => (9) <br>";
The answer is:
0 => (09)
9 => (9)
That's because any number preceded by 0 is treated as an octal number, and 9 is an invalid octal number. Octal numbers are base 8, e.g.:
| Octal Value | Decimal Value
|
| 1 | 1
|
| 2 | 2
|
| 3 | 3
|
| 4 | 4
|
| 5 | 5
|
| 6 | 6
|
| 7 | 7
|
| 10 | 8
|
| 11 | 9
|
The silly thing is that hardly anyone uses octal nowadays, but it continues to be part of the C, C++, Java and PHP standards. The mistake is also very common. C-style languages pride themselves in their terse and minimalist syntax, but this is one scenario where a language design error was probably made. Perhaps 0c should have been used to represent octal in analogy to 0x for hexadecimal, but this suggestion is sadly 35 years too late. 0 for octal is too deeply imprinted in modern compiler DNA.
PS: Here's the mistaken ADOdb bug report that started it.