From:             chris at chrisseaton dot com
Operating system: Linux
PHP version:      4.3.2
PHP Bug Type:     Scripting Engine problem
Bug description:  Itterative variable not editable in a for loop

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 bug report at http://bugs.php.net/?id=24300&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=24300&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=24300&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=24300&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=24300&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=24300&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=24300&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=24300&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=24300&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=24300&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=24300&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24300&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=24300&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=24300&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=24300&r=gnused

Reply via email to