From: az at kreatiefer dot de Operating system: Ubuntu 9.04 PHP version: 5.3.0 PHP Bug Type: *General Issues Bug description: logicerror in boolean cast from string
Description: ------------ When you cast a string variable to boolean type there are some cases in which the cast doesn't work properly, i think. Reproduce code: --------------- $arrTestVars = array( '0', '-0', '+0', '0.0', '0e0', '0.0e0' ); foreach($arrTestVars as $strTestVar) { var_dump( (bool)$strTestVar ); } Expected result: ---------------- // Expected Result => (bool)false, (bool)false, (bool)false, (bool)false, (bool)false, (bool)false All the tests above should be evaluated to false, because (bool)0.0 === false (bool)0e0 === false and so on. Now one has to use the workaround (bool)(int)'0.0' === false ... Actual result: -------------- // Actual Result => (bool)false, (bool)true, (bool)true, (bool)true, (bool)true, (bool)true -- Edit bug report at http://bugs.php.net/?id=49426&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49426&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49426&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49426&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49426&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49426&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49426&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49426&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49426&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49426&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49426&r=support Expected behavior: http://bugs.php.net/fix.php?id=49426&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49426&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49426&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49426&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49426&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49426&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49426&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49426&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49426&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49426&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49426&r=mysqlcfg