|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-10-07 19:23 UTC] jesus dot perez at infpormax dot es
[2010-10-08 02:23 UTC] cataphract@php.net
-Status: Open
+Status: Bogus
[2010-10-08 02:23 UTC] cataphract@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 02:00:01 2025 UTC |
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.