php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3727 <= test change on a string used as a loop index changes its size
Submitted: 2000-03-04 19:22 UTC Modified: 2000-03-05 11:40 UTC
From: tesio at easynet dot fr Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.12 OS: Linux RedHat 5.2 2.0.36
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tesio at easynet dot fr
New email:
PHP Version: OS:

 

 [2000-03-04 19:22 UTC] tesio at easynet dot fr
for ($a="A";$a<"Z";$a++) { echo $a; }

ABCDEFGHIJKLMNOPQRSTUVWXY

When you replace < with <= the variable is now on
two characters :

for ($a="A";$a<="Z";$a++) { echo $a; }

ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG ... YZ

Sorry I can't test in in the newest version, I don't own
the machine, there is nothing in the ChangeLog about this
problem.

live phpinfo here if needed :
http://www.onesite.org/phpinfo.php3

Regards,
Alain Tesio

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-03-05 11:40 UTC] sas at cvs dot php dot net
The result is correct.

You change the condition of the for loop, thus PHP will run until the string $a becomes larger than "Z". In PHP, "Z" + 1 is "AA", that is why you see two letter combinations.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 01:01:32 2025 UTC