#24300 [Fbk->NoF]: Itterative variable not editable in a for loop
| From: | sniper@php.net | Date: | Mon, 30 Jun 2003 02:19:03 +0000 |
| Subject: | #24300 [Fbk->NoF]: Itterative variable not editable in a for loop | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-42786@lists.php.net to get a copy of this message | ||
ID: 24300
Updated by: sniper@php.net
Reported By: chris at chrisseaton dot com
-Status: Feedback
+Status: No Feedback
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.3.2
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2003-06-23 22:04:10] sniper@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Works as expected with PHP versions 4.2.3, 4.3.1, 4.3.3-dev..
------------------------------------------------------------------------
[2003-06-23 14:41:11] chris at chrisseaton dot com
Eratta: Obviously, I mean "if ($n == 2)"
------------------------------------------------------------------------
[2003-06-23 14:36:56] chris at chrisseaton dot com
Description:
------------
If you are in a "for" loop you can't modify the itterative variable.
PHP seems to revert it the value at the start of the itteration.
This is standard behaviour for both C and Java. The PHP documentation
does not forbid this, and the syntax suggests it is possible, so I
assume this is a bug and not a design decision.
Reproduce code:
---------------
for ($n = 0; $n < 4; $n++)
{
print("$n\n");
if ($n = 2)
$n = 4;
}
Expected result:
----------------
0
1
2
Actual result:
--------------
0
1
2
3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24300&edit=1