php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75096 FILTER_NULL_ON_FAILURE null for not only boolean
Submitted: 2017-08-19 13:45 UTC Modified: 2021-06-10 10:32 UTC
From: aaatoja at o2 dot pl Assigned: cmb (profile)
Status: Closed Package: Filter related
PHP Version: 7.1.8 OS: Debian
Private report: No CVE-ID: None
 [2017-08-19 13:45 UTC] aaatoja at o2 dot pl
Description:
------------
According to http://php.net/manual/en/filter.filters.flags.php

FILTER_NULL_ON_FAILURE is described as "Returns NULL for unrecognized boolean values.", used with FILTER_VALIDATE_BOOLEAN.

But this flag also affects other, non-boolean, filters.

Test script:
---------------
var_dump(filter_var("123a", FILTER_VALIDATE_EMAIL, FILTER_NULL_ON_FAILURE)); // null
var_dump(filter_var("123a", FILTER_VALIDATE_EMAIL)); // false

var_dump(filter_var("123a", FILTER_VALIDATE_INT, FILTER_NULL_ON_FAILURE)); // null
var_dump(filter_var("123a", FILTER_VALIDATE_INT)); //false

var_dump(filter_var("123a", FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE)); // null
var_dump(filter_var("123a", FILTER_VALIDATE_IP)); //false

// etc


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-04 22:54 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Documentation problem +Package: Filter related
 [2021-06-10 10:32 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC