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

phpis_int(mixed $value): bool

Example

Let's check an integer:

php<?php
  $res = is_int(123);
  var_dump($res);
?>

Code execution result:

phptrue

Example

Let's check a string containing a number:

php<?php
  $res = is_int('123');
  var_dump($res);
?>

Code execution result:

phpfalse

Example

Let's check a floating-point number:

php<?php
  $res = is_int(12.34);
  var_dump($res);
?>

Code execution result:

phpfalse

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