What are some potential pitfalls when using is_int() in PHP?

One potential pitfall when using is_int() in PHP is that it only checks if a variable is of type integer, not if it contains an actual integer value. This means that a string containing numbers will not pass the is_int() check. To accurately check if a variable is an integer value, you can use is_numeric() instead.

// Incorrect usage of is_int()
$number = "10";
if(is_int($number)){
    echo "This is an integer";
} else {
    echo "This is not an integer";
}

// Correct usage of is_numeric()
$number = "10";
if(is_numeric($number) && (int)$number == $number){
    echo "This is an integer";
} else {
    echo "This is not an integer";
}