note 105499 added to arrayobject.offsetset

From: Date: Mon, 22 Aug 2011 22:58:01 +0000
Subject: note 105499 added to arrayobject.offsetset
Groups: php.notes 
Request: Send a blank email to php-notes+get-182666@lists.php.net to get a copy of this message
On my php 5.3.5 installation, i discovered that value can be set by reference and not by copy ... depending the context.. so this is différent from what a regular array() <?php function set(&$x, &$a ) { $x[] = $a; } $x = new ArrayObject(); $y = array(); $z = new ArrayObject(); $a = array( 'foo' ); set($y,$a); set($x,$a); $z[]=$a; $a = array( 'bar'); set($x,$a); set($y,$a); $z[]=$a; print_r($x); print_r($y); print_r($z); ?> // output ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( [0] => bar ) [1] => Array ( [0] => bar ) ) ) Array ( [0] => Array ( [0] => foo ) [1] => Array ( [0] => bar ) ) ArrayObject Object ( [storage:ArrayObject:private] => Array ( [0] => Array ( [0] => bar ) [1] => Array ( [0] => bar ) ) ) ---- Server IP: 89.31.146.176 Probable Submitter: 82.67.73.53 ---- Manual Page -- http://www.php.net/manual/en/arrayobject.offsetset.php Edit -- https://master.php.net/note/edit/105499 Del: integrated -- https://master.php.net/note/delete/105499/integrated Del: useless -- https://master.php.net/note/delete/105499/useless Del: bad code -- https://master.php.net/note/delete/105499/bad+code Del: spam -- https://master.php.net/note/delete/105499/spam Del: non-english -- https://master.php.net/note/delete/105499/non-english Del: in docs -- https://master.php.net/note/delete/105499/in+docs Del: other reasons-- https://master.php.net/note/delete/105499 Reject -- https://master.php.net/note/reject/105499 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182666) next »