How can the PHP function ctype_digit be used to determine if a variable contains a digit?

The PHP function ctype_digit can be used to determine if a variable contains only digits. This function returns true if all characters in the variable are numeric digits. To use this function, simply pass the variable as an argument to ctype_digit. If the function returns true, then the variable contains only digits.

$variable = "12345";
if (ctype_digit($variable)) {
    echo "The variable contains only digits.";
} else {
    echo "The variable does not contain only digits.";
}