is_int()
is_int() — Find whether the type of a variable is integer.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
is_int(mixed $value): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $value | mixed | The variable being evaluated. |
Return value
Returns true if value is an int, false otherwise.
Example
A runnable snippet:
$values = array(23, "23", 23.5, "23.5", null, true, false); foreach ($values as $value) { echo "is_int("; var_export($value); echo ") = "; var_dump(is_int($value)); }
Output:
is_int(23) = bool(true) is_int('23') = bool(false) is_int(23.5) = bool(false) is_int('23.5') = bool(false) is_int(NULL) = bool(false) is_int(true) = bool(false) is_int(false) = bool(false)
See also
is_bool(), is_float(), is_numeric(), is_string(), is_array(), is_object()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page is_int() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.