/** * Validate a value as integer * * @static * * @param mixed $value * * @return int|bool int or false in case of failure to convert to int */ public static function validate_int($value) { if (!isset(self::$has_filters)) { self::$has_filters = extension_loaded('filter'); } if (self::$has_filters) { return filter_var($value, FILTER_VALIDATE_INT); } else { return self::emulate_filter_int($value); } }