From: pmichaud at pobox dot com Operating system: Linux PHP version: 4.3.6 PHP Bug Type: *General Issues Bug description: Strings beginning with "inf" improperly converted
Description: ------------ PHP seems to incorrectly convert strings beginning with "inf" to INF (infinity). This includes converting strings such as "info" and "inflammable". Surprisingly, the strings "inf" and "infinity" do *not* convert to infinity but correctly become zeros. A script that illustrates the problem is given below: This is very annoying because one cannot simply do a test for a positive number with code such as if ($x>0) { echo "$x is positive"; } because if $x is any string beginning with "inf" (but not "inf" or "infinity") it is treated as a positive number. Pm Reproduce code: --------------- Here's a script that illustrates the problem: <?php header("Content-type: text/plain"); $a = "into"; $b = "info"; $c = "inf"; $d = "infinity"; $e = "infin"; $f = "inflammable"; echo "a: $a == ",$a+0,"\n"; # outputs 0 (correct) echo "b: $b == ",$b+0,"\n"; # outputs INF, incorrect! echo "c: $c == ",$c+0,"\n"; # outputs 0 (?!) echo "d: $d == ",$d+0,"\n"; # outputs 0 (?!) echo "e: $e == ",$e+0,"\n"; # outputs INF, incorrect! echo "f: $f == ",$f+0,"\n"; # outputs INF, incorrect! ?> Expected result: ---------------- a: into == 0 b: info == 0 c: inf == 0 d: infinity == 0 e: infin == 0 f: inflammable == 0 Actual result: -------------- a: into == 0 b: info == INF c: inf == 0 d: infinity == 0 e: infin == INF f: inflammable == INF -- Edit bug report at http://bugs.php.net/?id=28800&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28800&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28800&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28800&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28800&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28800&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28800&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28800&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28800&r=support Expected behavior: http://bugs.php.net/fix.php?id=28800&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28800&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28800&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28800&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28800&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28800&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28800&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28800&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28800&r=float