[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/random_compat/ -> cast_to_int.php (summary)

Random_* Compatibility Library for using the new PHP 7 random_* API in PHP 5 projects The MIT License (MIT)

File Size: 77 lines (3 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 function

  RandomCompat_intval()

Functions
Functions that are not part of a class:

RandomCompat_intval($number, $fail_open = false)   X-Ref
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 <= and => operators might accidentally let a float
through.

param: int|float $number    The number we want to convert to an int
param: bool      $fail_open Set to true to not throw an exception
return: float|int



Generated: Sun Jul 9 01:00:02 2023 Cross-referenced by PHPXref 0.7.1