PHP手册:数字示例1中的数字转换?

PHP手册:数字示例1中的数字转换?,php,evaluation,isnumeric,Php,Evaluation,Isnumeric,我在PHP文档中遇到了这个示例: <?php $tests = array( "42", 1337, 0x539, 02471, 0b10100111001, 1337e0, "not numeric", array(), 9.1 ); foreach ($tests as $element) { if (is_numeric($element)) { echo "'{$element}' i

我在PHP文档中遇到了这个示例:

<?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;
    }
}
?>
“42”之后的五个示例都评估为“1337”。我能理解为什么“1337e0”(科学记数法)会出现这种情况,但我不理解为什么其他人会出现这种情况


我在文档的注释中找不到任何人提到它,我也没有在这里找到它,所以有人能解释为什么“0x539”、“02471”和“0B101001111001”都计算为“1337”。

输出所有数字时都转换为正常表示。它是十进制数字系统和非科学表示法(例如
1e10
-科学浮点数)

十六进制:

十六进制数以
0x
开头,后跟
0-9a-f
中的任何一个

八进制:

八进制数以
0
开头,只包含整数0-7

二进制:

二进制数以
0b
开头,包含
0
s和/或
1
s


它们是八进制数、十六进制数和二进制数

'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
0x539 = 9*16^0 + 3*16^1 + 5*16^2 = 1337
02471 = 1*8^0 + 7*8^1 + 4*8^2 + 2*8^3 = 1337
0b10100111001 = 1*2^0 + 1*2^3 + 1*2^4 + 1*2^5 + 1*2^8 + 1*2^10 = 1337