It's good to remember that using filter_var is primarily for filtering input values when doing boolean logic comparisons.Take the following:$value = "12";if(filter_var($value, FILTER_VALIDATE_INT))The above works as intended, except when $value = "0".FILTER_VALIDATE_URL does not work with URNs, examples of valid URIs according to RFC3986 and if they are accepted by FILTER_VALIDATE_URL: [PASS] ftp://example.org/rfc/rfc1808[PASS] gopher://spinaltap.example.edu/00/Weather/California/Los Angeles [PASS] mailto:[email protected][PASS] news:comp.[PASS] telnet://example.edu/ [PASS] ldap://[2001:db8::7]/c=GB? in the domain part, a comment in the source code (in ext/filter/logical_filters.c) justifies this rejection thus: * The regex below is based on a regex by Michael Rushton. I changed it to only consider routeable * addresses as valid.
In 2007 someone suggested it's not acceptable (see https://net/bug.php?
I think "Beware a valid URL need not specify..." would be better.
FILTER_VALIDATE_EMAIL is discarding valid e-mail addresses containing IDN.
id=40156&edit=2) but it was flagged "not a bug" because these kind of filters are only supposed to filter out illegal characters.
Of course if you were to use FILTER_VALIDATE_FLOAT it would just return that the input is not valid.