Bug #67754 [Opn]: "for" judge A-Z error.
| From: | datibbaw@php.net | Date: | Mon, 04 Aug 2014 07:48:38 +0000 |
| Subject: | Bug #67754 [Opn]: "for" judge A-Z error. | ||
| References: | 1 | Groups: | php.standards |
| Request: | Send a blank email to standards-+get-297@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67754&edit=1
ID: 67754
Updated by: datibbaw@php.net
Reported by: yppah56 at yahoo dot com dot tw
Summary: "for" judge A-Z error.
Status: Open
Type: Bug
Package: PHP Language Specification
Operating System: Linux(Ubuntu13.4)
PHP Version: 5.4.31
Block user comment: N
Private report: N
New Comment:
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) {
}
Previous Comments:
------------------------------------------------------------------------
[2014-08-04 07:36:25] 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;
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67754&edit=1