is_int
Checks whether a value is an integer.
Syntax
is_int(mixed $value): boolParameters
| Parameter | Type | Description |
|---|---|---|
| $value | mixed | The value to check. |
Return value
bool`true` if the type of the value is `int`.
Examples
An integer, a float and a string:
<?php
var_dump(is_int(42));
var_dump(is_int(42.0));
var_dump(is_int('42'));Output:
bool(true)
bool(false)
bool(false)Notes
The function checks the type, not how the value looks. Form data always arrives as strings — those need filter_var($value, FILTER_VALIDATE_INT).
See also
- is_numeric — Checks whether a value is a number or a numeric string.
- is_string — Checks whether a value is a string.
- intval — Converts a value to an integer.
In the tutorial
- Data types — The main PHP data types — strings, numbers, booleans, arrays and null.