Is this link sufficent for example for input filtering form data? With a post for example?
<?php
$var=300;
$int_options = array(
"options"=>array
(
"min_range"=>0,
"max_range"=>256
)
);
if(!filter_var($var, FILTER_VALIDATE_INT, $int_options))
{
echo("Integer is not valid");
}
else
{
echo("Integer is valid");
}
?>
What is the most common kind of filtering? Like sanitizing strings and numbers. I use preg_match for validation of email fields on the server side and regular expression checks in javascript. I'm no validation nazi but would like to have some sort of filtering for the most common things.
These kind of things I think I could abstract away in my application with some public static functions in a class for example, like this
Validate::String($str);
Validate::Interger($int);
What do you think about that?