#42136 [NEW]: filter_var() fails for "0"
| From: | gnupun at yahoo dot com | Date: | Sun, 29 Jul 2007 09:38:10 +0000 |
| Subject: | #42136 [NEW]: filter_var() fails for "0" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-115525@lists.php.net to get a copy of this message | ||
From: gnupun at yahoo dot com
Operating system: Windows XP
PHP version: 5.2.3
PHP Bug Type: Filter related
Bug description: filter_var() fails for "0"
Description:
------------
filter_var() design is broken... the following code always returns FALSE:
filter_var() obviously needs two outputs: the filtered value and a
success/failure code.
($value, $errcode) = filter_var(...
Reproduce code:
---------------
$myint = "0";
if (!filter_var($myint, FILTER_VALIDATE_INT)) {
echo "$myint is not an integer\n";
}
else {
echo "$myint is an integer\n";
}
Expected result:
----------------
0 is an integer
Actual result:
--------------
0 is not an integer
--
Edit bug report at http://bugs.php.net/?id=42136&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42136&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42136&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42136&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42136&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42136&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42136&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42136&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42136&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42136&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42136&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42136&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42136&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42136&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42136&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42136&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42136&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42136&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42136&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42136&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42136&r=mysqlcfg