From:             rschwartz at ec dot rr dot com
Operating system: Any
PHP version:      4.3.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Comparison Operators not working with alpha characters

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

Reply via email to