The filter_input() function gets a name of external variable and filters it optionally.
Syntax
filter_input(type, var, filtername, options)
Parameters
type − There are five types of inputs to check i.e. INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.
var − The name of variable.
filtername − The name of filter to get ID.
options − Specifies options to use.
Return
The filter_input() function returns the value of the variable on success, false on failure, or null if the parameter of variable is not set.
Example
<?php if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)) { echo "E-Mail isn't valid!"; } else { echo "E-Mail is valid!"; } ?>
Output
The following is the output.
E-Mail isn't valid!