Hacker News new | ask | show | jobs
by tsm 2026 days ago
Edit: I was wrong. 0123 is octal, not decimal

[Incorrect original post: 0123 evaluates to the integer value 123]

3 comments

Not quite - 0123 is the octal value 123 which happens to be 83 in decimal. Numbers starting with a 0 in PHP are assumed to be in octal but I this isn't the case for strings[1] - to add to confusion "123foo" == 123 => true but "0123foo" = 0123 => false.

1. https://3v4l.org/hAoL2

But the integer part of the string "0123foo" is also 123
So ?
0123 (octal) != 123 (int)