Re: Serializing objects, using __sleep and __wakeup?
| From: | Andrei Zmievski | Date: | Fri, 07 Jul 2000 13:39:20 +0000 |
| Subject: | Re: Serializing objects, using __sleep and __wakeup? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-23804@lists.php.net to get a copy of this message | ||
On Fri, 07 Jul 2000, David Eriksson wrote:
>
> I have a few classes in my CORBA extension, and I want them to work
> transparently with PHP:s session management, they need to be serializable.
>
> Right now I believe that value.obj.properties is serialized, but there I
> just store an index to a list of internal data... (like the COM extension)
>
> I looked in ext/session/session.c and ext/standard/var.c and it seems like
> it is possible to make member functions called __sleep and __wakeup, which
> might be what I need.
>
> Can anyone explain how these work? I have not been able to find any docs
> or examples that explain this.
__sleep() is called when the object is being serialized. It's supposed
to return an array of names of object properties that should be
serialized.
__wakeup() is called after all the object properties have been
deserialized/instantiated. It should be used for any additional
initialization, if necessary.
-Andrei
* 2 + 2 = 5 for extremely large values of 2. *