Bug #55373 [Opn->Bgs]: Unexpected behavior involving conditions.
| From: | arpad@php.net | Date: | Sat, 06 Aug 2011 02:25:22 +0000 |
| Subject: | Bug #55373 [Opn->Bgs]: Unexpected behavior involving conditions. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-162450@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=55373&edit=1
ID: 55373
Updated by: arpad@php.net
Reported by: computerboy0 at gmail dot com
Summary: Unexpected behavior involving conditions.
-Status: Open
+Status: Bogus
Type: Bug
Package: Scripting Engine problem
Operating System: OS X 10.5.8 (Irrelevant)
PHP Version: Irrelevant
Block user comment: N
Private report: 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
Please see http://www.php.net/manual/en/language.operators.precedence.php
&& has a higher precedence than = so the result of that expression is correctly false.
Previous Comments:
------------------------------------------------------------------------
[2011-08-06 01:44:24] computerboy0 at gmail dot com
Description:
------------
Using IF or WHILE statements (possibly others?), the code below produces
unexpected results.
Test script:
---------------
//Set a variable with an initial value.
$TEST="Initial";
//Set the variable to a different value, then test for it.
if($TEST="Secondary" && $TEST==="Secondary") echo "Expected result
occurred.";
else echo "Expectation FAIL";
//During the ($TEST==="Secondary") condition, $TEST should match "Secondary",
having just been set to "Secondary". Instead, there $TEST is actually still
"Initial".
echo "\n".$TEST;
Expected result:
----------------
$TEST should be set to "Secondary" within the IF statement and then reflect that
within said IF statement. It does not seem to.
Script result:
Expected result occurred.
Secondary
Actual result:
--------------
What actually happens is that $TEST only becomes "Secondart" *after* the entire IF
statement has processed. So any following comparison with $TEST still yields its
initial value.
Script result:
Expectation FAIL
Secondary
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=55373&edit=1