|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-06-23 14:41 UTC] chris at chrisseaton dot com
[2003-06-23 22:04 UTC] sniper@php.net
[2003-06-29 21:19 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 08:00:01 2025 UTC |
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