filter_var()` function :<?php
$int = "1234";
if (filter_var($int, FILTER_VALIDATE_INT)) {
echo("$int is a valid integer");
} else {
echo("$int is not a valid integer");
}
?>1234 is a valid integer$int` and assign it the value `"1234"`. We then use the `filter_var()` function to validate this variable as an integer using the `FILTER_VALIDATE_INT` filter.