ID: 26914
Comment by: psyko at wyred dot mine dot nu
Reported By: rschwartz at ec dot rr dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Any
PHP Version: 4.3.4
New Comment:
Same for version 4.3.3
Previous Comments:
------------------------------------------------------------------------
[2004-01-15 04:09:28] rschwartz at ec dot rr dot com
Description:
------------
I was testing a for loop with incrementing alpha characters. For
example, looping through a-z and printing those characters. It does
not seem to work as expected.
Reproduce code:
---------------
Ex 1:
for ($i = 'a'; $i <= 'z'; $i++) {
echo $i;
}
Ex 2:
for ($i = 'a'; $i < 'z'; $i++) {
echo $i;
}
Ex 3:
for ($i = 'a'; $i < 'aa'; $i++) {
echo $i;
}
Expected result:
----------------
Ex 1: Print a-z.
Ex 2: Print a-y.
Ex 3: Print a-z.
Actual result:
--------------
Ex1 loops through to 'yz' and does not work as expected.
Ex2 loops through to 'z', which is expected.
Ex3 dies after the first iteration and only prints 'a'.
I think this is an odd behavior. The < operator works as expected in
this example but the <= operator does not. It doesn't seem like a
consistent behavior. If I can remember correctly, I was able to get
this to work on an earlier version sometime ago.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26914&edit=1