I ran across this example in the PHP documentation:
<?php
$tests = array(
"42",
1337,
0x539,
02471,
0b10100111001,
1337e0,
"not numeric",
array(),
9.1
);
foreach ($tests as $element) {
if (is_numeric($element)) {
echo "'{$element}' is numeric", PHP_EOL;
} else {
echo "'{$element}' is NOT numeric", PHP_EOL;
}
}
?>
Output:
'42' is numeric
'1337' is numeric
'1337' is numeric
'1337' is numeric
'1337' is numeric
'1337' is numeric
'not numeric' is NOT numeric
'Array' is NOT numeric
'9.1' is numeric
The five examples after '42' all evaluate to '1337'. I can understand why this is the case for '1337e0' (scientific notation), but I don't understand why that is the case for the rest of them.
I wasn't able to find anyone mentioning it in the comments of the documentation and I haven't found it asked here, so could anyone explain why '0x539', '02471', and '0b10100111001' all evaluate to '1337'.