What does a leading zero do for a php int?

If you use a leading zero, the number is interpreted by PHP as an octal number. Thus, a 9 is not a valid part of the number and the parser stops there:

  0730320 (base 8)
=  7 * 8^5 + 3 * 8^4 + 3 * 8^2 + 2 * 8^1
=  7 * 32768 + 3 * 4096 + 3 * 64 + 2 * 8 (base 10)
=  241872 (base 10)

Leave a Comment