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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 14:01:29 2024 UTC