Bug #73345 [NEW]: loose type comparison fault affecting in_array

From: Date: Wed, 19 Oct 2016 08:09:16 +0000
Subject: Bug #73345 [NEW]: loose type comparison fault affecting in_array
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204911@lists.php.net to get a copy of this message
From: matt at h-bs dot co Operating system: any PHP version: 7.0.12 Package: Math related Bug Type: Bug Bug description:loose type comparison fault affecting in_array Description: ------------ although this is documented in the loose comparison section @ http://php.net/manual/en/types.comparisons.php, the failure of php to evaluate any string (loosely) against numeric 0 correctly is causing issues in 'in_array', and possibly some others(?). I realise that the problem can be worked around with strict flags/syntax, but it seems odd that this bug can be allowed to survive? Maybe its my understanding of the core thats flawed, and theres a perfectly good explanation as to why a string evaluates to true against numeric 0, but it feels properly broken to me. many thanks. Matt Test script: --------------- $array = array( 'test', 0 ); var_dump(in_array('xxx', $array)); var_dump('test' == 0); Expected result: ---------------- false false Actual result: -------------- true true -- Edit bug report at https://bugs.php.net/bug.php?id=73345&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73345&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73345&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73345&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73345&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73345&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73345&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73345&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73345&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73345&r=support Expected behavior: https://bugs.php.net/fix.php?id=73345&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73345&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73345&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73345&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73345&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73345&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73345&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73345&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73345&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73345&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73345&r=mysqlcfg

« previous php.bugs (#204911) next »