note 17706 deleted from language.references by sniper

From: Date: Tue, 30 Sep 2003 01:17:45 +0000
Subject: note 17706 deleted from language.references by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57303@lists.php.net to get a copy of this message
Note Submitter: ---- Succesive assignement by reference and simple assignement : $a = 'old'; $b = &$a; $a = 'new';// now $b's value is new $c = $b;// simple copy $a = 'new new'; // $b is 'new new', $c is still 'new' And now with arrays : $a[0] = 'old'; $b = &$a; $c = $b;//simple copy $a[0] = 'new';// $b[0] is new, and $c[0] is still 'old' BUT : $a = 'old'; $b[0] = &$a; $c = $b; // simple copy $a = 'new';//now BOTH $b[0] and $c[0] are 'new' A simple copying of an array (or an object) does NOT break references for the values (or instance variables). Use var_dump() to see which of the values in an array are references. Ivan

« previous php.notes (#57303) next »