Often I see some code like the following:$value = "12";if( filter_var($value, FILTER_VALIDATE_INT) )The above works as intended, except when $value is "0". For the correct behavior, you have not only to check if it is equal (==) to false, but also identic (===) to FALSE:$value = " 0 ";if( filter_var($value, FILTER_VALIDATE_INT) === FALSE )I hope, I could help.
Note that if using FILTER_NULL_ON_FAILURE as a flag with the FILTER_VALIDATE_BOOLEAN id then NULL is no longer returned if the variable name is not set in the external variable array. In the description is says that when using the FILTER_NULL_ON_FAILURE flag that ' FALSE is returned only for "0", "false", "off", "no", and ""' an makes no mention of this additional state that can also return false.
The behavior is mentioned on the filter_input documentation page under Return Values but that is not overly helpful if one is just looking here.
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.
Michael's regex considers [email protected] a valid address * which conflicts with section 2.3.5 of RFC 5321 which states that: * * Only resolvable, fully-qualified domain names (FQDNs) are permitted * when domain names are used in SMTP.