|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 Patchesbug72543_3.diff (last revision 2016-07-06 00:31 UTC by dmitry@php.net)bug72543_2.diff (last revision 2016-07-05 19:57 UTC by dmitry@php.net) bug72543.diff (last revision 2016-07-05 10:45 UTC by dmitry@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits              [2016-07-04 13:32 UTC] tony2001@php.net
 
-Status:      Open
+Status:      Assigned
-Assigned To:
+Assigned To: dmitry
  [2016-07-04 15:52 UTC] laruence@php.net
  [2016-07-04 17:02 UTC] dmitry@php.net
  [2016-07-05 03:17 UTC] laruence@php.net
  [2016-07-05 09:58 UTC] dmitry@php.net
  [2016-07-05 10:45 UTC] dmitry@php.net
  [2016-07-05 11:19 UTC] laruence@php.net
  [2016-07-05 19:57 UTC] dmitry@php.net
  [2016-07-06 00:31 UTC] dmitry@php.net
  [2016-07-06 17:46 UTC] dmitry@php.net
  [2016-07-06 17:46 UTC] dmitry@php.net
 
-Status: Assigned
+Status: Closed
  [2016-07-06 17:49 UTC] dmitry@php.net
  [2016-07-20 11:30 UTC] davey@php.net
  [2016-10-17 10:11 UTC] bwoebi@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 03:00:01 2025 UTC | 
Description: ------------ Looks like references behavior has changed in 7.x comparing to 5.5. First of all, once variable becomes reference, it never looses that flag, even though the second reference is already destroyed (see the first function "create_references"). Second, I'm able to change the original variable by passing its copy to a function and modifying it there, which is definitely counter-intuitive. I expected the function to copy the variable to write, since it was not passed by reference, as that's what seems to be happening in PHP 5.5 Test script: --------------- /* after this function all array elements become references */ function create_references(&$array) { $refs[] = &$array; foreach ($array as $key => $value) { create_references($array[$key]); } } /* a copy is passed and then modified, which also modifies the original variable */ function change_copy($copy) { for ($i = 0; $i < 2; $i++) { $copy['b']['b'] = $copy['b']; //this causes recursion } } $data = [ 'a' => [ 'b' => [], ], ]; create_references($data); $copy = $data['a']; var_dump($data); change_copy($copy); var_dump($data); //RECURSION Expected result: ---------------- array(1) { ["a"]=> array(1) { ["b"]=> array(0) { } } } array(1) { ["a"]=> array(1) { ["b"]=> array(0) { } } } Actual result: -------------- array(1) { ["a"]=> array(1) { ["b"]=> array(0) { } } } array(1) { ["a"]=> array(1) { ["b"]=> array(1) { ["b"]=> *RECURSION* } } }