rest_is_integer() WordPress Function

The rest_is_integer() function can be used to check whether a given value is an integer or not. This is useful when dealing with values that may be strings or integers.

rest_is_integer( mixed $maybe_integer ) #

Determines if a given value is integer-like.


Parameters

$maybe_integer

(mixed)(Required)The value being evaluated.


Top ↑

Return

(bool) True if an integer, otherwise false.


Top ↑

Source

File: wp-includes/rest-api.php

function rest_is_integer( $maybe_integer ) {
	return is_numeric( $maybe_integer ) && round( (float) $maybe_integer ) === (float) $maybe_integer;
}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More