Bug #70733 [Opn]: int/string conversion bug in arrays
Edit report at https://bugs.php.net/bug.php?id=70733&edit=1
ID: 70733
Updated by: ab@php.net
Reported by: bfanger at gmail dot com
Summary: int/string conversion bug in arrays
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: El Capitan
-PHP Version: 7.0.0RC5
+PHP Version: irrelevant
Block user comment: N
Private report: N
New Comment:
Reproduced even with 5.5.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-10-17 15:43:16] bfanger at gmail dot com
Description:
------------
Reading and writing to an array could lead to new array entries (with an integer key) instead of
overwriting the value.
This even leads weird json output using which uses same key twice, but that's an other issue.
Test script:
---------------
$object = json_decode('{"200": true}');
$data = get_object_vars($object);
$data['200'] = false;
echo json_encode($data, JSON_PRETTY_PRINT);
Expected result:
----------------
{
"200": false
}
Actual result:
--------------
{
"200": true,
"200": false
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70733&edit=1
Thread (7 messages)