#31458 [NEW]: 0 == '%' is true?
From: falk at brockerhoff dot org Operating system: FreeBSD 5.3 PHP version: 4.3.10 PHP Bug Type: Unknown/Other Function Bug description: 0 == '%' is true? Description: I got a strange problem while comparing a numeric while with the string %. Using the numeric value 0 and the string % in an if-statement results with true!? Reproduce code: --- $foo = '%'; $bar = 0; if ($foo == $var) { echo what the hell is going on?!\n; } $foo = '%'; $bar = '0'; if ($foo == $var) { echo what the hell is going on?!\n; } -- Edit bug report at http://bugs.php.net/?id=31458edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31458r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31458r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31458r=trysnapshot51 Fixed in CVS:http://bugs.php.net/fix.php?id=31458r=fixedcvs Fixed in release:http://bugs.php.net/fix.php?id=31458r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=31458r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=31458r=needscript Try newer version: http://bugs.php.net/fix.php?id=31458r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=31458r=support Expected behavior: http://bugs.php.net/fix.php?id=31458r=notwrong Not enough info: http://bugs.php.net/fix.php?id=31458r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=31458r=submittedtwice register_globals:http://bugs.php.net/fix.php?id=31458r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31458r=php3 Daylight Savings:http://bugs.php.net/fix.php?id=31458r=dst IIS Stability: http://bugs.php.net/fix.php?id=31458r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=31458r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=31458r=float No Zend Extensions: http://bugs.php.net/fix.php?id=31458r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=31458r=mysqlcfg
#31458 [Bgs-Csd]: 0 == '%' is true?
ID: 31458 User updated by: falk at brockerhoff dot org Reported By: falk at brockerhoff dot org -Status: Bogus +Status: Closed Bug Type: Unknown/Other Function Operating System: FreeBSD 5.3 PHP Version: 4.3.10 New Comment: Oh, it's not a bug, it's a feature: http://www.php.net/manual/en/language.operators.comparison.php Previous Comments: [2005-01-09 21:58:39] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Use === to compare variables of different types and read the documentation about type juggling. [2005-01-09 21:51:53] falk at brockerhoff dot org Description: I got a strange problem while comparing a numeric while with the string %. Using the numeric value 0 and the string % in an if-statement results with true!? Reproduce code: --- $foo = '%'; $bar = 0; if ($foo == $var) { echo what the hell is going on?!\n; } $foo = '%'; $bar = '0'; if ($foo == $var) { echo what the hell is going on?!\n; } -- Edit this bug report at http://bugs.php.net/?id=31458edit=1