#33622 [Opn->Bgs]: $i++ is not $i+1
| From: | helly@php.net | Date: | Sat, 09 Jul 2005 12:43:35 +0000 |
| Subject: | #33622 [Opn->Bgs]: $i++ is not $i+1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-81613@lists.php.net to get a copy of this message | ||
ID: 33622
Updated by: helly@php.net
Reported By: meh at v-cm dot net
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Windows XP
PHP Version: 4.3.11
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
Previous Comments:
------------------------------------------------------------------------
[2005-07-09 14:36:22] meh at v-cm dot net
Description:
------------
The operators ++ and -- don't increment/decrement boolean values.
This behaviour could be extremly annoying when you have something
like:
$key = array_search($thekey, array_keys($thearray));
for($i=$key; $x<count($thearray); $i++)
echo "foo";
Workaround:
$key = array_search($thekey, array_keys($thearray));
if($key==false) $key=0;
for($i=$key; $x<count($thearray); $i++)
echo "foo";
If this behaviour is intended, then it should at least be documented
that ++,-- doens't convert boolean values.
Reproduce code:
---------------
// Works
$x = false;
echo $x+1; // Outputs 1
// Doesn't work
$x= false;
$x++;
echo $x; // Outputs nothing
Expected result:
----------------
11
Actual result:
--------------
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33622&edit=1