|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-03-27 15:00 UTC] looris at gmail dot com
Description:
------------
While I agree that it would be better to actually initialize elements before using them, it is anyway wrong that they behave in inconsistent ways when you do that.
They should BOTH count as 0, hence become 1 and -1, OR they should **BOTH** stay NULL.
It does not make any sense at all to have them behave in two different ways.
Test script:
---------------
$pitale=array();
$pitale["ok"]++;
$pitale["bug"]--;
print_r($pitale);
Expected result:
----------------
Array
(
[ok] => 1
[bug] => -1
)
---OR---
Array
(
[ok] =>
[bug] =>
)
Actual result:
--------------
Array
(
[ok] => 1
[bug] =>
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 03:00:01 2025 UTC |
The documentation claims The increment/decrement operators do not affect boolean values. Decrementing NULL values has no effect too, but incrementing them results in 1. http://php.net/manual/en/language.operators.increment.php This might be considered inconsistent but changing this would be a rather random compatibility break.