From:             thomas dot keller at inatec dot com
Operating system: Linux Mandrake 8, Linux 2.4.3
PHP version:      4.3.9
PHP Bug Type:     Scripting Engine problem
Bug description:  Wrong loop handling when using chars instead of integers

Description:
------------
Configure command:
'./configure' '--prefix=/usr/local/php'
'--with-apxs2=/home/apache2/apache-2.0.52/bin/apxs' '--enable-versioning'
'--with-mysql=/usr/local/mysql' '--with-gd' '--with-zlib'

I use the following code snippet to print out an array
of chars in alphabetic order. If I have the condition
$i < 'Z' (so only until 'Y'), everything works fine, 
for the condition(s) $i <= 'Z' or $i < ('A' + 26)
PHP produces wrong results.

I could reproduce the error on a Redhat 9 system with PHP 4.3.4.

Reproduce code:
---------------
$letters = array();

for ($i='A'; $i<='Z'; $i++) print $i;



Expected result:
----------------
ABCDEFGHIJKLMNOPQRSTUVWXYZ

(26 ^ 1 letters)

Actual result:
--------------
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABAC .. YZ

(26 ^ 2 letters)


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

Reply via email to