From: [EMAIL PROTECTED] Operating system: linux 2.2.20, linux 2.4.19 PHP version: 4.2.3 PHP Bug Type: Scripting Engine problem Bug description: echo 'foo'==0 ? 'is true ' : 'is false ' outputs 'is true'
sorry, im really not sure if this is a kind of bug or if i'm getting something wrong: the two lines echo 'foo'==0 ? 'is true ' : 'is false '; if('bar'==0) echo 'is true '; else echo 'is false '; will output: is true is true i dont understand why 'foo'==0 returns true. the way i understand the manual, php should consider 'foo' a nonempty string and 0 a zero integer. even if it would do a boolean comparison, according to the manual 'foo' should be juggled to true and 0 should be juggled to false. how can 'foo'==0 return true? have i missed something? i hope i do not resubmit a known issue, i tried some queries but i really didnt know how to lookup this issue. this happens with variables as well. i ran into this problem in my programming when comparing array keys that could be numeric or string. a 0 array key compared against any nonempty string array key always returned true. it took me a while to find out that's why my program didnīt work the way i thought it should. i hope this is not something that happens only to me, but i have tested the two lines on three different boxes before writing to you. my configure line: ./configure' '--with-mysql=/usr/local/mysql' '--with-apache=../apache_1.3.26' '--enable-ftp' '--with-zlib-dir=/usr/lib' Best regards, wolfgang -- Edit bug report at http://bugs.php.net/?id=20708&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20708&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20708&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20708&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20708&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20708&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20708&r=support Expected behavior: http://bugs.php.net/fix.php?id=20708&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20708&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20708&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20708&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20708&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20708&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20708&r=isapi