Why does
var_dump(16) // displays int(16)
but
var_dump(016) // displays int(14)
Anyone can help me solve this problem?
Why does
var_dump(16) // displays int(16)
but
var_dump(016) // displays int(14)
Anyone can help me solve this problem?
The second value is called octal. It's not the same as base 10. Instead it's base 8. When you add the 0
in front it tells PHP to treat it as an octal.
http://php.net/manual/en/language.types.integer.php
Integers can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8) or binary (base 2) notation, optionally preceded by a sign (- or +).
To use octal notation, precede the number with a 0 (zero).
10 in base 8 is 8
6 in base 8 is 6
8 + 6 = 14