|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2017-05-06 10:35 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2017-05-06 10:35 UTC] requinix@php.net
[2017-05-08 02:11 UTC] winbill at hotmail dot com
[2017-05-08 03:50 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 16:00:02 2025 UTC |
Description: ------------ PHP references cause unexpected results I tested the following script under php 5.3 & 5.6 & 7.0.17 All of them, c2 output {"foo":2}, not {"foo":1} $a = array('foo' => 1); $c1 = $a; $b = &$a['foo']; $c2 = $a; $b = 2; printf("c1:%s\n", json_encode($c1)); printf("c2:%s\n", json_encode($c2)); // output c2:{"foo":2} ! Test script: --------------- $a = array('foo' => 1); $c1 = $a; $b = &$a['foo']; $c2 = $a; $b = 2; printf("c1:%s\n", json_encode($c1)); printf("c2:%s\n", json_encode($c2)); // output c2:{"foo":2} ! Expected result: ---------------- c1:{"foo":1} c2:{"foo":1} Actual result: -------------- c1:{"foo":1} c2:{"foo":2}