|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57163 Empty string with FILTER_VALIDATE_INT returns 0
Submitted: 2006-07-28 14:08 UTC Modified: 2006-08-31 14:30 UTC
From: Jared dot Williams1 at ntlworld dot com Assigned: pajoye (profile)
Status: Closed Package: filter (PECL)
PHP Version: 5.2.0 RC1 OS: Win200
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.
Block user comment
Status: Assign to:
Bug Type:
From: Jared dot Williams1 at ntlworld dot com
New email:
PHP Version: OS:


 [2006-07-28 14:08 UTC] Jared dot Williams1 at ntlworld dot com
An empty string with FILTER_VALIDATE_INT returns 0. I would expect it to return false. 

Reproduce code:
var_dump(filter_data($var, FILTER_VALIDATE_INT));

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-28 20:37 UTC] pierre dot php at gmail dot com
I'm not sure it should be false here. I will leave it like that for now. Let see what other people thinks first.
 [2006-08-03 05:23 UTC] x dot philbert at pixandlog dot com
It's not a good idea to return false value for empty field.
Why ? If you return false value for empty field, so you don't identify error value.
$test = ''; //return 0
$test2 = 'ABCD'; //return false
If you want identify empty value, use is_empty or isset before filter_data.
You can return a good error message between 'You don't fill the field' and 'You don't correctly answer in field'.
Exemple : What your age ?
Client has answered empty field.
Server test the value (input_get return 0) and return 'Sorry you don't have good age'.
Thank you for your job.
When will out the next release ?
 [2006-08-17 13:28 UTC] philip at roshambo dot org
During testing I assumed it would return false here but assume reasons exist for the 0 instead.  It feels wrong to not know if a user entered in a empty string versus a 0 but I don't offer a strong opinion or solution.
 [2006-08-31 14:30 UTC] pierre dot php at gmail dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

Got 5 other mails about the same issues, I agree to now :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 30 07:01:30 2024 UTC