&reftitle.examples;
Validation
Validating email addresses with filter_var
]]>
&example.outputs;
Validating IP addresses with filter_var
]]>
&example.outputs;
Passing options to filter_var
array(
'min_range' => 0,
'max_range' => 3,
)
);
if (filter_var($int_a, FILTER_VALIDATE_INT, $options) !== FALSE) {
echo "Integer A '$int_a' is considered valid (between 0 and 3).\n";
}
if (filter_var($int_b, FILTER_VALIDATE_INT, $options) !== FALSE) {
echo "Integer B '$int_b' is considered valid (between 0 and 3).\n";
}
if (filter_var($int_c, FILTER_VALIDATE_INT, $options) !== FALSE) {
echo "Integer C '$int_c' is considered valid (between 0 and 3).\n";
}
$options['options']['default'] = 1;
if (($int_c = filter_var($int_c, FILTER_VALIDATE_INT, $options)) !== FALSE) {
echo "Integer C '$int_c' is considered valid (between 0 and 3).";
}
?>
]]>
&example.outputs;
Sanitization
Sanitizing and validating email addresses
]]>
&example.outputs;
Configuring a default filter