php - When using the is_int function, when the number to be determined exceeds 9 digits, false is returned. Why?
大家讲道理
大家讲道理 2017-05-16 13:04:03
0
2
1018

When using the is_int function, PHP returns false when the number to be determined exceeds 9 digits. Why?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
滿天的星座

. . . .
Integer integer type has a range, and this range is different from the range of 32-bit (maximum value: 2^31 - 1) and 64-bit (maximum value: 2^63 - 1) related to the platform version. At this time, numbers out of the range will be interpreted as float type, so the is_int() function judgment will be false. The following is a 64-bit integer overflow:

$large_number = 9223372036854775807;
var_dump(is_int($large_number));                     // true

$large_number = 9223372036854775808;
var_dump(is_int($large_number));                    // false
世界只因有你

According to php official website manual:

The word length of integers is platform-dependent, although the usual maximum is about two billion (32-bit signed). The maximum value on 64-bit platforms is usually around 9E18, except for versions prior to PHP 7 on Windows, which were always 32-bit. PHP does not support unsigned integer. The word length of an Integer value can be represented by the constant PHP_INT_SIZE. Since PHP 4.4.0 and PHP 5.0.5, the maximum value can be represented by the constant PHP_INT_MAX, and the minimum value can be represented by the constant PHP_INT_MIN in PHP 7.0.0 and later versions. .

So for a 32-bit integer, signed 2^31=2147483648 (about 2 billion), it is a 10-digit number, so for the situation you mentioned, it is true that more than 9 digits will return false.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template