From: Operating system: Linux version 2.6.35-22-generic- PHP version: 5.3.3 Package: Unknown/Other Function Bug Type: Bug Bug description:'or' and '?:' operators has diferent behaviors
Description: ------------ The test script returns the following: 0 or 2 or 1 => 1 0 ?: 2 ?: 1 => 2 0 or 2 ?: 1 => 1 0 ?: 2 or 1 => 1 Is it desired? Test script: --------------- <?php $a = 0; $b = 2; $c = 1; echo $a.' or '.$b.' or '.$c.' => '; echo $a or $b or $c; echo "<br>\n"; echo $a.' ?: '.$b.' ?: '.$c.' => '; echo $a ?: $b ?: $c; echo "<br>\n"; echo $a.' or '.$b.' ?: '.$c.' => '; echo $a or $b ?: $c; echo "<br>\n"; echo $a.' ?: '.$b.' or '.$c.' => '; echo $a ?: $b or $c; echo "<br>\n"; Expected result: ---------------- 0 or 2 or 1 => 2 0 ?: 2 ?: 1 => 2 0 or 2 ?: 1 => 2 0 ?: 2 or 1 => 2 Actual result: -------------- 0 or 2 or 1 => 1 0 ?: 2 ?: 1 => 2 0 or 2 ?: 1 => 1 0 ?: 2 or 1 => 1 -- Edit bug report at http://bugs.php.net/bug.php?id=53168&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53168&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53168&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53168&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53168&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53168&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53168&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53168&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53168&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53168&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53168&r=support Expected behavior: http://bugs.php.net/fix.php?id=53168&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53168&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53168&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53168&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53168&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53168&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53168&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53168&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53168&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53168&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53168&r=mysqlcfg