Bug #54635 [NEW]: Decrementing character variables does not work as expected

From: Date: Fri, 29 Apr 2011 13:57:28 +0000
Subject: Bug #54635 [NEW]: Decrementing character variables does not work as expected
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160451@lists.php.net to get a copy of this message
From:             
Operating system: win32
PHP version:      Irrelevant
Package:          Strings related
Bug Type:         Bug
Bug description:Decrementing character variables does not work as expected

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


-- 
Edit bug report at http://bugs.php.net/bug.php?id=54635&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=54635&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=54635&r=trysnapshot53
Try a snapshot (trunk):              http://bugs.php.net/fix.php?id=54635&r=trysnapshottrunk
Fixed in SVN:                        http://bugs.php.net/fix.php?id=54635&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54635&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=54635&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=54635&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=54635&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=54635&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=54635&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=54635&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=54635&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=54635&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=54635&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=54635&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=54635&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=54635&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=54635&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=54635&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=54635&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=54635&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#160451) next »