note 77235 added to function.ArrayObject-construct

From: Date: Tue, 21 Aug 2007 08:56:43 +0000
Subject: note 77235 added to function.ArrayObject-construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-129662@lists.php.net to get a copy of this message
Note that the first argument to ArrayObject::__construct, the initial array, is passed by reference. Nevertheless, modification of the array doesn't modify the object, so it may cause unexpected behaviour. <?php $array = array('foo' => 'initial'); $obj = new ArrayObject($array); // array was passed by reference: $obj['foo'] = 'modified'; var_dump($array); // foo => modified // but it doesn't work backwards: $array['foo'] = 'modified_again'; var_dump($obj); // foo => modified var_dump($array); // foo => modified_again ?> ---- Server IP: 195.54.192.44 Probable Submitter: 212.5.113.133 ---- Manual Page -- http://www.php.net/manual/en/function.ArrayObject-construct.php Edit -- https://master.php.net/note/edit/77235 Del: integrated -- https://master.php.net/note/delete/77235/integrated Del: useless -- https://master.php.net/note/delete/77235/useless Del: bad code -- https://master.php.net/note/delete/77235/bad+code Del: spam -- https://master.php.net/note/delete/77235/spam Del: non-english -- https://master.php.net/note/delete/77235/non-english Del: in docs -- https://master.php.net/note/delete/77235/in+docs Del: other reasons-- https://master.php.net/note/delete/77235 Reject -- https://master.php.net/note/reject/77235 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#129662) next »