Bug #53168 [Opn->Bgs]: 'or' and '?:' operators has diferent behaviors
| From: | felipe@php.net | Date: | Tue, 26 Oct 2010 14:44:10 +0000 |
| Subject: | Bug #53168 [Opn->Bgs]: 'or' and '?:' operators has diferent behaviors | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-155533@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53168&edit=1
ID: 53168
Updated by: felipe@php.net
Reported by: lealcy at gmail dot com
Summary: 'or' and '?:' operators has diferent behaviors
-Status: Open
+Status: Bogus
Type: Bug
Package: Unknown/Other Function
Operating System: Linux version 2.6.35-22-generic-
PHP Version: 5.3.3
Block user comment: N
New Comment:
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
See http://docs.php.net/manual/en/language.operators.logical.php
Previous Comments:
------------------------------------------------------------------------
[2010-10-26 16:34:12] lealcy at gmail dot com
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 this bug report at http://bugs.php.net/bug.php?id=53168&edit=1