#30732 [Opn->Bgs]: Wrong loop handling when using chars instead of integers
| From: | mgf@php.net | Date: | Tue, 09 Nov 2004 14:10:03 +0000 |
| Subject: | #30732 [Opn->Bgs]: Wrong loop handling when using chars instead of integers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-68847@lists.php.net to get a copy of this message | ||
ID: 30732
Updated by: mgf@php.net
Reported By: thomas dot keller at inatec dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux Mandrake 8, Linux 2.4.3
PHP Version: 4.3.9
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
When you use ++ on strings, the sequence of values is:
... 'X', 'Y', 'Z', 'AA', 'AB', ... 'AZ',
'BA', ...
Only when this sequence reaches 'ZA' does it fail the <='Z' test.
Previous Comments:
------------------------------------------------------------------------
[2004-11-09 11:07:12] thomas dot keller at inatec dot com
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 this bug report at http://bugs.php.net/?id=30732&edit=1