Bug #79604 [NEW]: OR and || returning different results with arrays

From: Date: Fri, 15 May 2020 17:04:44 +0000
Subject: Bug #79604 [NEW]: OR and || returning different results with arrays
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227057@lists.php.net to get a copy of this message
From: shariefjamiel at gmail dot com Operating system: mac/ubuntu PHP version: 7.4Git-2020-05-15 (Git) Package: Arrays related Bug Type: Bug Bug description:OR and || returning different results with arrays Description: ------------ I noticed the OR operator was not working properly with a value inside an array, Test script: --------------- /** * PHP 7.2.24-0ubuntu0.18.04.1 (cli) (built: Oct 28 2019 12:07:07) ( NTS ) * PHP 7.4.5 (cli) (built: Apr 23 2020 02:25:56) ( NTS ) * @see https://www.php.net/manual/en/language.operators.logical.php */ $array = [ 'a' => 'php', 'b' => false ]; # EXPECTED BEHAVIOR $check = $array['b'] === true || $array['a'] === 'php'; // should and is true var_dump($check); # ACTUAL RESULT $check = $array['b'] === true or $array['a'] === 'php'; // should be true var_dump($check); # START SANITY CHECKS # Sanity Check 1 var_dump(true === true or 'php' === 'php'); // should be and is true # Sanity Check 2 $a = true; $b = 'php'; var_dump($a === true or $b === 'php'); // should be and is true Expected result: ---------------- bool(true) bool(true) bool(true) bool(true) Actual result: -------------- bool(true) bool(false) bool(true) bool(true) -- Edit bug report at https://bugs.php.net/bug.php?id=79604&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79604&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79604&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79604&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79604&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79604&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79604&r=support Expected behavior: https://bugs.php.net/fix.php?id=79604&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79604&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79604&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79604&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79604&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79604&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79604&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79604&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79604&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79604&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79604&r=mysqlcfg

« previous php.bugs (#227057) next »