Try online the filter_var PHP function

This tool allows you to try directly online the PHP filter_var on the input of your choice. The available filter and flags are all the possible ones on PHP.

Details on the PHP function filter_var

There are 2 types of fitlers available for the filter_var functions. Some of these delimiters also have flags that can be used to customize their behavior.

1. Validate filters

This filters are going to return a boolean value. These are simply telling if the content matches the filter of not.


Filter Flags Description
FILTER_VALIDATE_BOOLEAN FILTER_NULL_ON_FAILURE Returns TRUE for "1", "true", "on" and "yes". Returns FALSE otherwise.

If FILTER_NULL_ON_FAILURE is set, FALSE is returned only for "0", "false", "off", "no", and "", and NULL is returned for all non-boolean values.
FILTER_VALIDATE_EMAIL Validates whether the value is a valid e-mail address.

In general, this validates e-mail addresses against the syntax in RFC 822, with the exceptions that comments and whitespace folding are not supported.
FILTER_VALIDATE_FLOAT FILTER_FLAG_ALLOW_THOUSAND Validates value as float, and converts to float on success.
FILTER_VALIDATE_INT FILTER_FLAG_ALLOW_OCTAL
FILTER_FLAG_ALLOW_HEX
Validates value as integer, optionally from the specified range, and converts to int on success.
FILTER_VALIDATE_IP FILTER_FLAG_IPV4
FILTER_FLAG_IPV6
FILTER_FLAG_NO_PRIV_RANGE
FILTER_FLAG_NO_RES_RANGE
Validates value as IP address, optionally only IPv4 or IPv6 or not from private or reserved ranges.
FILTER_VALIDATE_MAC Validates value as MAC address.
FILTER_VALIDATE_REGEXP Validates value against regexp, a Perl-compatible regular expression.
FILTER_VALIDATE_URL FILTER_FLAG_PATH_REQUIRED
FILTER_FLAG_QUERY_REQUIRED
Validates value as URL, optionally with required components. Beware a valid URL may not specify the HTTP protocol http:// so further validation may be required to determine the URL uses an expected protocol, e.g. ssh:// or mailto:. Note that the function will only find ASCII URLs to be valid; internationalized domain names (containing non-ASCII characters) will fail.
2. Sanitize filters

This filters are going to return a possibly modified values of the input. It will delete all the content that should not be in. After going through the sanitize function an input will return true to the corresponding validate filter.


Filter Flags Description
FILTER_SANITIZE_EMAIL Remove all characters except letters, digits and !#$%&'*+-=?^_`{|}~@.[].
FILTER_SANITIZE_ENCODED FILTER_FLAG_STRIP_LOW
FILTER_FLAG_STRIP_HIGH
FILTER_FLAG_ENCODE_LOW
FILTER_FLAG_ENCODE_HIGH
URL-encode string, optionally strip or encode special characters.
FILTER_SANITIZE_MAGIC_QUOTES Apply the PHP function addslashes()
FILTER_SANITIZE_NUMBER_FLOAT FILTER_FLAG_ALLOW_FRACTION
FILTER_FLAG_ALLOW_THOUSAND
FILTER_FLAG_ALLOW_SCIENTIFIC
Remove all characters except digits, +- and optionally .,eE.
FILTER_SANITIZE_NUMBER_INT Remove all characters except digits, plus and minus sign.
FILTER_SANITIZE_SPECIAL_CHARS FILTER_FLAG_STRIP_LOW
FILTER_FLAG_STRIP_HIGH
FILTER_FLAG_ENCODE_HIGH
HTML-escape '"<>& and characters with ASCII value less than 32, optionally strip or encode other special characters.
FILTER_SANITIZE_FULL_SPECIAL_CHARS FILTER_FLAG_NO_ENCODE_QUOTES Equivalent to calling htmlspecialchars() with ENT_QUOTES set. Encoding quotes can be disabled by setting FILTER_FLAG_NO_ENCODE_QUOTES. Like htmlspecialchars(), this filter is aware of the default_charset and if a sequence of bytes is detected that makes up an invalid character in the current character set then the entire string is rejected resulting in a 0-length string. When using this filter as a default filter, see the warning below about setting the default flags to 0.
FILTER_SANITIZE_STRING FILTER_FLAG_NO_ENCODE_QUOTES
FILTER_FLAG_STRIP_LOW
FILTER_FLAG_STRIP_HIGH
FILTER_FLAG_ENCODE_LOW
FILTER_FLAG_ENCODE_HIGH
FILTER_FLAG_ENCODE_AMP
Strip tags, optionally strip or encode special characters.
FILTER_SANITIZE_STRIPPED Alias of the filter "string".
FILTER_SANITIZE_URL Remove all characters except letters, digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=.
FILTER_UNSAFE_RAW FILTER_FLAG_STRIP_LOW
FILTER_FLAG_STRIP_HIGH
FILTER_FLAG_ENCODE_LOW
FILTER_FLAG_ENCODE_HIGH
FILTER_FLAG_ENCODE_AMP
Do nothing, optionally strip or encode special characters. This filter is also aliased to FILTER_DEFAULT.


 FR     EN  

Copyright 2024 -   Contact us - 2024-11-21 08:46:39