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: 2017-09-04 22:54 UTC
From: aaatoja at o2 dot pl Assigned:
Status: Verified Package: Filter related
PHP Version: 7.1.8 OS: Debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-04 22:54 UTC] cmb@php.net
-Status: Open +Status: Verified -Package: Documentation problem +Package: Filter related
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC