note 81642 deleted from language.oop.serialization by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 19:12:44 +0000 |
| Subject: | note 81642 deleted from language.oop.serialization by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162595@lists.php.net to get a copy of this message | ||
Note Submitter: PaulK
----
Balduran, here is the solution to your problem:
http://us.php.net/manual/en/language.oop5.magic.php#81492
and here is the working code:
class A {
public $a1 = 'a1';
protected $a2 = 'a2';
private $a3 = 'a3';
public function __sleep() {
return array("a1", "\0*\0a2", "\0A\0a3");
}
}
class B extends A {
public $b1 = 'b1';
public $b2 = 'b2';
public $b3 = 'b3';
public function __sleep() {
return array_merge(array("b1", "b2", "b3"),
parent::__sleep());
}
}
print_r(unserialize(serialize(new B())));