- var_dump: documentation ( source)
- unserialize: documentation ( source)
- serialize: documentation ( source)
<?php
class ObjectWithReferences {
protected $var1;
protected $var2;
public function __construct() {
$this->var1 = new StdClass();
$this->var2 = $this->var1;
}
}
class WrapperObject implements Serializable
{
static $tempstorage;
protected $obj;
public function setObject($obj) {
$this->obj = $obj;
}
public function getObject() {
return $this->obj;
}
public function serialize() {
return serialize($this->obj);
}
public function unserialize($serialized) {
$this->obj = unserialize($serialized);
}
}
$owr = new ObjectWithReferences();
$wrapper = new WrapperObject();
$wrapper->setObject($owr);
var_dump($wrapper->getObject());
$wrapper = unserialize(serialize($wrapper));
var_dump($wrapper->getObject());