PHP Filter_input Function

What is filter_input function in PHP?


filter_input is a function, which gets the external variables and filters them.


filter_input(input_type, variable, filter, options)

In the above syntax, 'input_type' is the type in which the input is passed, 'filter_args' is the array of external variables.

Example :

<?php if (!filter_input(INPUT_GET, 'email', FILTER_VALIDATE_EMAIL))
echo "E-Mail is not valid";
} else
echo "E-Mail is valid";
} ?

Result :

E-Mail is valid

In the above example, the external variables Email is validated.
The value IS passed through url for the test.php file as follows,
Since, THE value is valid the above output is retrieved.

PHP Topics

Ask Questions

Ask Question