&reftitle.examples;
Validación
Validación de direcciones de correo con filter_var
]]>
&example.outputs;
Validación de direcciones IP con filter_var
]]>
&example.outputs;
Pasando opciones a filter_var
array(
'min_range' => 0,
'max_range' => 3,
)
);
if (filter_var($int_a, FILTER_VALIDATE_INT, $options) !== FALSE) {
echo "Este entero (int_a) es válido (entre 0 y 3).\n";
}
if (filter_var($int_b, FILTER_VALIDATE_INT, $options) !== FALSE) {
echo "Este entero (int_b) es válido (entre 0 y 3).\n";
}
if (filter_var($int_c, FILTER_VALIDATE_INT, $options) !== FALSE) {
echo "Este entero (int_c) es válido (entre 0 y 3).\n";
}
$options['options']['default'] = 1;
if (($int_c = filter_var($int_c, FILTER_VALIDATE_INT, $options)) !== FALSE) {
echo "Este entero (int_c) es válido (entre 0 y 3) y es $int_c.";
}
?>
]]>
&example.outputs;
Saneamiento
Saneando y validando direcciones de correo
]]>
&example.outputs;
Configuración de un filtro por omisión