The is_int Function
The is_int
function checks if the passed value is an integer.
Returns true
if the value is an integer, and false
otherwise.
The function accepts one parameter - the value to check.
Syntax
is_int(mixed $value): bool
Example
Let's check an integer:
<?php
$res = is_int(123);
var_dump($res);
?>
Code execution result:
true
Example
Let's check a string containing a number:
<?php
$res = is_int('123');
var_dump($res);
?>
Code execution result:
false
Example
Let's check a floating-point number:
<?php
$res = is_int(12.34);
var_dump($res);
?>
Code execution result:
false
See Also
-
the
is_float
function,
which checks for a floating-point number -
the
is_numeric
function,
which checks if a value is a number or a string containing a number