public static function isInt($value)
{
/**
* we exit here if not is_numeric, because str_replace below will cast bools
* to numerics
*/
if (is_object($value) || is_bool($value)) {
return false;
}
$locale = localeconv();
// convert decimal sep
$value = str_replace($locale['decimal_point'], '.', $value);
// remove thousands sep
$value = str_replace($locale['thousands_sep'], '', $value);
// Must be an integer (no floats or e-powers))
if (preg_replace("/^-?([0-9]+)\$/", "", $value) !== "") {
return false;
}
// Must be greater than than min of 64-bit
if (bccomp($value, "-9223372036854775807") < 0) {
return false;
}
// Must be less than max of 64-bit)
if (bccomp($value, "9223372036854775807") > 0) {
return false;
}
return true;
}