note 112289 modified in language.types.array by danbrown
| From: | danbrown@php.net | Date: | Wed, 05 Jun 2013 17:43:26 +0000 |
| Subject: | note 112289 modified in language.types.array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-195066@lists.php.net to get a copy of this message | ||
Note that array value buckets are reference-safe, even through serialization.
<?php
$x='initial';
$test=array('A'=>&$x,'B'=>&$x);
$test=unserialize(serialize($test));
$test['A']='changed';
echo $test['B']; // Outputs "changed"
?>
This can be useful in some cases, for example saving RAM within complex structures.
--was--
Note that array value buckets are reference-safe, even through serialization.
$x='initial';
$test=array('A'=>&$x,'B'=>&$x);
$test=unserialize(serialize($test));
$test['A']='changed';
echo $test['B']; // Outputs "changed"
This can be useful in some cases, for example saving RAM within complex structures.
http://php.net/manual/en/language.types.array.php