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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: aaatoja at o2 dot pl
New email:
PHP Version: OS:

 

 [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
 [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: Sat May 04 22:01:33 2024 UTC