This extension filters data by either validating or sanitizing it. This is especially useful when the data source contains unknown data, like user supplied input. For example, this data may come from an HTML form.
Validation is used to validate or check if the data meets certain qualifications. For example, passing in FILTER_VALIDATE_EMAIL will determine if the data is a valid email address, but will not change the data itself.
Sanitization will sanitize the data, so it may alter it by removing undesired characters. For example, passing in FILTER_SANITIZE_EMAIL will remove characters that are inappropriate for an email address to contain. That said, it does not validate the data.
Function |
Description |
---|---|
filter_has_var |
Checks if variable of specified type exists |
filter_id |
Returns the filter ID belonging to a named filter |
filter_input_array |
Gets external variables and optionally filters them |
filter_input |
Gets a specific external variable by name and optionally filters it |
filter_list |
Returns a list of all supported filters |
filter_var_array |
Gets multiple variables and optionally filters them |
filter_var |
Filters a variable with a specified filter |
<?php $email = "bharat.makwana@Veewom.com"; if (!filter_var($email, FILTER_VALIDATE_EMAIL) === false) { echo("$email is a valid email address"); } else { echo("$email is not a valid email address"); } ?>