php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54635 Decrementing character variables does not work as expected
Submitted: 2011-04-29 15:57 UTC Modified: 2011-04-29 17:34 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: reto dot kohli at comvation dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: Irrelevant OS: win32
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
49 - 16 = ?
Subscribe to this entry?

 
 [2011-04-29 15:57 UTC] reto dot kohli at comvation dot com
Description:
------------
In the documentation (http://www.php.net/manual/en/language.operators.increment.php), "Example #1 Arithmetic Operations on Character Variables" shows how strings can be incremented.
You would expect this to work the opposite way, too -- however, it doesn't.
See the modified code from Example #1 attached.


Test script:
---------------
$i = 'W';
for ($n=0; $n<6; $n++) {
    echo --$i . "\n";
}


Expected result:
----------------
V
U
T
S
R
Q


Actual result:
--------------
W
W
W
W
W
W


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-29 15:59 UTC] reto dot kohli at comvation dot com
-Status: Open +Status: Closed
 [2011-04-29 15:59 UTC] reto dot kohli at comvation dot com
It is documented...  :(
 [2011-04-29 17:34 UTC] dtajchreber@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 13:01:28 2024 UTC