note 51103 deleted from language.oop.serialization by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 19:12:56 +0000 |
| Subject: | note 51103 deleted from language.oop.serialization by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162602@lists.php.net to get a copy of this message | ||
Note Submitter: fdreger at amiga dot pl
----
It seems that serializing an object dereferences all its attributes that were references - even if
the object they referenced was contained within the serialized one.
Consider this example:
<?
class foo {
var $a=new array();
}
$example=new foo;
$obj=new whatever();
$example->a[]=&$obj;
$example->a[]=$obj;
//now $example contains a list with
//both: an object and a reference to that object
//let us serialize and immediately unserialize $example:
$string=serialize(example);
$example=unserialize(string);
//now the situation is completely different!
//$example contains just two identical objects,
//the reference is lost
?>