How does the is_int() function work in PHP and what does it specifically check for?

The is_int() function in PHP checks whether a variable is an integer or not. It specifically checks if the variable is of type integer. This function can be used to validate user input or to ensure that a variable is an integer before performing mathematical operations on it.

$number = 42;

if (is_int($number)) {
    echo "The variable is an integer.";
} else {
    echo "The variable is not an integer.";
}