PHP FILTER_VALIDATE_INT Filter
What is FILTER_VALIDATE_INT in PHP?
Explanation
PHP FILTER_VALIDATE_INT is used to check whether the given integer value is valid or not.
Name: "int"
ID-number: 257
Possible options and flags:
min_range | specifies the minimum integer value |
max_range | specifies the maximum integer value |
FILTER_FLAG_ALLOW_OCTAL | allows octal number values |
FILTER_FLAG_ALLOW_HEX | allows hexadecimal number values |
Example :
<?php
$val=25;
$opt = array("options"=>
array("min_range"=>0, "max_range"=>70));
if(filter_var($val, FILTER_VALIDATE_INT, $opt))
{
echo "Valid Integer Value";
}
else
{
echo "Invalid Integer";
}
?>
Result :
Valid Integer Value