#30732 [NEW]: Wrong loop handling when using chars instead of integers
| From: | thomas dot keller at inatec dot com | Date: | Tue, 09 Nov 2004 10:07:16 +0000 |
| Subject: | #30732 [NEW]: Wrong loop handling when using chars instead of integers | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-68838@lists.php.net to get a copy of this message | ||
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