From: Operating system: Ubuntu 8.04.4 LTS PHP version: Irrelevant Package: Unknown/Other Function Bug Type: Bug Bug description:FILTER_VALIDATE_INT treats float as integer
Description: ------------ PHP's filter extension erroneous validates a float (10.) as integer. The observed behaviour in filter extension is not consistent to is_int()/is_float() type checks whereas 10. is reported to be float. In addition, the formal structure of integers *1) does not mention dots to be part of a valid integer. *1) http://www.php.net/manual/en/language.types.integer.php Environment: Server OS: Ubuntu 8.04.4 LTS PHP package in use: 5.2.4-2ubuntu5.10 Test script: --------------- $variableToTest = 10.; echo "This variable type is " . (is_int($variableToTest) ? 'integer' : 'not integer') . "!\n"; echo "This variable type is " . (is_float($variableToTest) ? 'float' : 'not float') . "!\n"; // validate integer echo "This variable is considered to be " . ((FALSE !== filter_var($variableToTest, FILTER_VALIDATE_INT)) ? 'integer' : 'not integer') . "!\n"; echo "This variable is considered to be " . ((FALSE !== filter_var((string)$variableToTest, FILTER_VALIDATE_INT)) ? 'integer' : 'not integer') . "!\n"; // validate float echo "This variable is considered to be " . ((FALSE !== filter_var($variableToTest, FILTER_VALIDATE_FLOAT)) ? 'float' : 'not float') . "!\n"; echo "This variable is considered to be " . ((FALSE !== filter_var((string)$variableToTest, FILTER_VALIDATE_FLOAT)) ? 'float' : 'not float') . "!\n"; Expected result: ---------------- This variable type is not integer! This variable type is float! This variable is considered to be not integer! This variable is considered to be not integer! This variable is considered to be float! This variable is considered to be float! Actual result: -------------- This variable type is not integer! This variable type is float! This variable is considered to be integer! This variable is considered to be integer! This variable is considered to be float! This variable is considered to be float! -- Edit bug report at http://bugs.php.net/bug.php?id=52884&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52884&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52884&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52884&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52884&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52884&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52884&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52884&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52884&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52884&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52884&r=support Expected behavior: http://bugs.php.net/fix.php?id=52884&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52884&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52884&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52884&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52884&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52884&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52884&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52884&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52884&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52884&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52884&r=mysqlcfg