PHP 7 filter_input() Function
Example
Check if the external variable "email" is sent to the PHP page, through the "get" method, and also check if it is a valid email address:
 <?php
if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_EMAIL)) {
    echo("Email is not valid");
} else {
    echo("Email is valid");
}
?>
Try it Yourself »
Definition and Usage
The filter_input() function gets an external variable (e.g. from form input) and optionally filters it.
This function is used to validate variables from insecure sources, such as user input.
Syntax
 filter_input(type, variable, filter, options)
| Parameter | Description | 
|---|---|
| type | Required. The input type to check for. Can be one of the following:
  
  | 
  
| variable | Required. The variable name to check | 
| filter | Optional. Specifies the ID or name of the filter to use. Default is FILTER_DEFAULT, which results in no filtering | 
| options | Optional. Specifies one or more flags/options to use. Check each filter for possible options and flags | 
Technical Details
| Return Value: | The value of the variable on success, FALSE on failure, or NULL if the variable is not set | 
|---|---|
| PHP Version: | 5.2+ | 
❮ Complete PHP Filter Reference

