PHP Filter_var Function
What is filter_var() in PHP?
filter_var() is a function, used to validate a value of a variable. This function returns the filtered data on success or FALSE on failure.
filter_var(variable, filter, options)
if (!filter_var($val, FILTER_VALIDATE_INT))
echo "This Value is not a number";
echo "This Value is a number";
This Value is a number
In the above example, the variable value stored in $val is 12344, which is a number. It is determined and validated using filter_var() function.