Edit report at http://bugs.php.net/bug.php?id=53015&edit=1

 ID:                 53015
 User updated by:    jesus dot perez at infpormax dot es
 Reported by:        jesus dot perez at infpormax dot es
 Summary:            Logic operator failure
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   Debian 5.0.5
 PHP Version:        5.2.14
 Block user comment: N

 New Comment:

There are a mistake at the email address

it must be 

jesus.pe...@informax.es

My apologies for the inconveniences


Previous Comments:
------------------------------------------------------------------------
[2010-10-07 19:21:25] jesus dot perez at infpormax dot es

Description:
------------
We found a problem with the logical operators, exactly with the "||" and
the "OR" operators.

We think both of them are the same, except for the precedence of each
one.

But when we run the script we show below, the results arent the same.

Is not a crash bug, but we found unexpected results using this
operators.

Thanks in advance



Test script:
---------------
<?php



$a = false;

$b = true;

$c = true;



$res10 = $a || $b || $c;

$res11 = ($a || $b) || $c;

$res12 = $a || ($b || $c);

$res13 = ($a || $b || $c);



$res20 = $a OR $b OR $c;

$res21 = ($a OR $b) OR $c;

$res22 = $a OR ($b OR $c);

$res23 = ($a OR $b OR $c);



echo ' TEST || <br />';



echo (int)$a." || ".(int)$b." || ".(int)$c." = ".(int)$res10." <br />";

echo "(".(int)$a." || ".(int)$b.") || ".(int)$c." = ".(int)$res11." <br
/>";

echo (int)$a." || (".(int)$b." || ".(int)$c.") = ".(int)$res12." <br
/>";

echo "(".(int)$a." || ".(int)$b." || ".(int)$c.") = ".(int)$res13." <br
/>";



echo ' <br />';

echo ' TEST OR<br />';



echo (int)$a." OR ".(int)$b." OR ".(int)$c." = ".(int)$res20." <br />";

echo "(".(int)$a." OR ".(int)$b.") OR ".(int)$c." = ".(int)$res21." <br
/>";

echo (int)$a." OR (".(int)$b." OR ".(int)$c.") = ".(int)$res22." <br
/>";

echo "(".(int)$a." OR ".(int)$b." OR ".(int)$c.") = ".(int)$res23." <br
/>";

?>



Expected result:
----------------
We except the same result for all the comparators. We think it must be
"true" all of them

Actual result:
--------------
The result is unexpected. The result is not the same using an "OR" or a
"||", but it must be the same.

is not a precedence problem  because we are using only one operator at
the same time.




------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53015&edit=1

Reply via email to