note 81642 added to language.oop.serialization

From: Date: Fri, 07 Mar 2008 16:39:10 +0000
Subject: note 81642 added to language.oop.serialization
Groups: php.notes 
Request: Send a blank email to php-notes+get-136824@lists.php.net to get a copy of this message
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()))); ---- Server IP: 92.48.74.199 Probable Submitter: 199.3.18.3 ---- Manual Page -- http://www.php.net/manual/en/language.oop.serialization.php Edit -- https://master.php.net/note/edit/81642 Del: integrated -- https://master.php.net/note/delete/81642/integrated Del: useless -- https://master.php.net/note/delete/81642/useless Del: bad code -- https://master.php.net/note/delete/81642/bad+code Del: spam -- https://master.php.net/note/delete/81642/spam Del: non-english -- https://master.php.net/note/delete/81642/non-english Del: in docs -- https://master.php.net/note/delete/81642/in+docs Del: other reasons-- https://master.php.net/note/delete/81642 Reject -- https://master.php.net/note/reject/81642 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136824) next »