Thursday, January 29, 2026
HomeLanguagesPHP is_integer() Function

PHP is_integer() Function

The is_integer() function is an inbuilt function in PHP that is used to check whether the type of a variable is an integer or not. This function is an alias of is_int() function.

Syntax:

bool is_integer(mixed $value)

Parameters: This function accepts a single parameter $value that holds the value which needs to check for integer.

Return Value: This function returns true if the value is an integer, and false otherwise.

Example 1:

PHP




<?php
  
$arr = array(5, 10.5, null, true, "GFG");
  
foreach ($arr as $val) {
    var_dump(is_integer($val));
}
  
?>


Output:

bool(true)
bool(false)
bool(false)
bool(false)
bool(false)

Example 2:

PHP




<?php
  
$arr = array(
    15, 
    10 => "Geeks",
    30.25, 
    "neveropen",
    '', 
    true, 
    50
);
  
foreach ($arr as $val) {
    var_dump(is_integer($val));
}
  
?>


Output:

bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)

Reference: https://www.php.net/manual/en/function.is-integer.php

RELATED ARTICLES

Most Popular

Dominic
32477 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6916 POSTS0 COMMENTS