php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67754 "for" judge A-Z error.
Submitted: 2014-08-04 07:36 UTC Modified: 2014-08-06 19:55 UTC
From: yppah56 at yahoo dot com dot tw Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.4.31 OS: Linux(Ubuntu13.4)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: yppah56 at yahoo dot com dot tw
New email:
PHP Version: OS:

 

 [2014-08-04 07:36 UTC] yppah56 at yahoo dot com dot tw
Description:
------------
0000
When for() judge 'Z', find error.

  for ($char='A'; $char<='Z'; $char++) echo $char;

Echo not as expected.
Maybe counting error.


Test script:
---------------
// this program is OK
for ($char='A'; $char<='Y'; $char++) {
  echo $char;
}


// this program is Error
for ($char='A'; $char<='Z'; $char++) {
  echo $char;
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-04 07:48 UTC] datibbaw@php.net
This happens because after 'Z' comes 'AA', and 'AA' is smaller than 'Z'.

The correct condition in this case is:

    $char != 'AA'

The other way (recommended):

    foreach (range('A', 'Z') as $char) {
    }
 [2014-08-04 07:48 UTC] datibbaw@php.net
-Status: Open +Status: Not a bug
 [2014-08-04 07:48 UTC] datibbaw@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2014-08-04 07:57 UTC] requinix@php.net
-Package: PHP Language Specification +Package: *General Issues
 [2014-08-06 19:55 UTC] yppah56 at yahoo dot com dot tw
for ($char='A'; $char<='Z'; $char++) {
    echo $char;
  }


Should print 

ABCDEFGHIJKLMNOPQRSTUVWXYZ


But print

ABCDEFG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