filter_var()
` function with the `FILTER_VALIDATE_INT
` filter.<?php
$number = 0;
if (filter_var($number, FILTER_VALIDATE_INT) !== false) {
echo "The number is a valid integer.";
} else {
echo "The number is not a valid integer.";
}
?>
The number is a valid integer.
$number
` with the value `0
`. We then use the `filter_var()
` function with the `FILTER_VALIDATE_INT
` filter to validate this variable as an integer.