randomcompat_intval
函数
randomcompat_intval ( $number, $fail_open = false )
- 参数
-
-
(int|float)
$number
The number we want to convert to an int- Required: 是
-
(bool)
$fail_open
Set to true to not throw an exception- Required: 否
- Default: false
-
(int|float)
- 返回值
-
- (float|int)
- 定义位置
-
-
wp-includes/random_compat/cast_to_int.php
, line 48
-
wp-includes/random_compat/cast_to_int.php
- 引入
- –
- 弃用
- –
Cast to an integer if we can, safely.
If you pass it a float in the range (~PHP_INT_MAX, PHP_INT_MAX)
(non-inclusive), it will sanely cast it to an int. If you it’s equal to
~PHP_INT_MAX or PHP_INT_MAX, we let it fail as not an integer. Floats
lose precision, so the operators might accidentally let a float
through.
function RandomCompat_intval($number, $fail_open = false) { if (is_int($number) || is_float($number)) { $number += 0; } elseif (is_numeric($number)) { /** @psalm-suppress InvalidOperand */ $number += 0; } /** @var int|float $number */ if ( is_float($number) && $number > ~PHP_INT_MAX && $number
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。