|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-07-22 15:34 UTC] jani@php.net
[2007-07-23 07:45 UTC] a dot yamanoi at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 23:00:01 2025 UTC |
Description: ------------ When ArrayObject::offsetSet() method stores a new value into an array, I expect ArrayObject to change only the array which is given as a constructor parameter. However, if the array is copied from another array and unchanged, ArrayObject will also change the another array. I thought it was a "copy-on-write" problem. thank you for any help Please excuse my English, it isn't very good. Reproduce code: --------------- $base = array('key' => 'old value'); $copy = $base; $ao = new ArrayObject($copy); $ao['key'] = 'new value'; echo '$base["key"] = ', $base['key'], "\n"; echo '$copy["key"] = ', $copy['key'], "\n"; echo '$ao["key"] = ', $ao['key'], "\n"; Expected result: ---------------- $base["key"] = old value $copy["key"] = new value $ao["key"] = new value Actual result: -------------- $base["key"] = new value $copy["key"] = new value $ao["key"] = new value