Bug->Doc #80212 [Opn]: Decrement operator doesn't work as stated in the manual
| From: | cmb@php.net | Date: | Sat, 10 Oct 2020 10:42:58 +0000 |
| Subject: | Bug->Doc #80212 [Opn]: Decrement operator doesn't work as stated in the manual | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17985@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80212&edit=1
ID: 80212
Updated by: cmb@php.net
Reported by: g dot a dot stamoulis at gmail dot com
Summary: Decrement operator doesn't work as stated in the
manual
Status: Open
-Type: Bug
+Type: Documentation Problem
Package: Strings related
Operating System: Linux
PHP Version: 7.4.11
Block user comment: N
Private report: N
New Comment:
The manual already states[1]:
| Note that character variables can be incremented but not
| decremented [â¦]
Maybe this important note should be more prominent.
Previous Comments:
------------------------------------------------------------------------
[2020-10-10 10:20:44] g dot a dot stamoulis at gmail dot com
Description:
------------
Strings can be incremented by the ++ operator but they don't get decremented by the --
operator. This is seems inconsistent and it is also not documented in the manual.
Test script:
---------------
<?php
$test = 'abc12';
// increment works as expected
echo(++$test . "\n");
echo(++$test . "\n");
echo(++$test . "\n");
// decrement fails
echo(--$test . "\n");
echo(--$test . "\n");
echo(--$test . "\n");
Expected result:
----------------
abc13
abc14
abc15
abc14
abc13
abc12
Actual result:
--------------
abc13
abc14
abc15
abc15
abc15
abc15
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80212&edit=1