From: tonglebeak at gmail dot com Operating system: Linux PHP version: 4.3.8 PHP Bug Type: Unknown/Other Function Bug description: if () statement not parsing decimals correctly
Description: ------------ Normally, whenever and int 0 is put into an if statement, the statement is returned as false. Same thing with double 0: it returns false. However, with a decimal, it's returning true. 0.0000000 is an example that is returning true. This can lead to possible security issues for those who rely on the if statement, and are using it on a decimal taken from a database for example for security checks and such. Reproduce code: --------------- <? $num='0.000000000'; if ($num) echo 'decimal true'; if ((int)$num) echo 'int true'; if ((double)$num) echo 'double true'; ?> Expected result: ---------------- I expect nothing to return true at all. Actual result: -------------- 'decimal true' is returned, meaning "if (0.000000000)" is returning true. -- Edit bug report at http://bugs.php.net/?id=30143&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30143&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30143&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30143&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30143&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30143&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30143&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30143&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30143&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30143&r=support Expected behavior: http://bugs.php.net/fix.php?id=30143&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30143&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30143&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30143&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30143&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30143&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30143&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30143&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30143&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30143&r=mysqlcfg