cool. you and i were talking about two different things. you are using
__sleep and __wakeup by issuing the serialize and unserialize commands
yourself.  i am using __sleep and __wakeup when php automatically issues
them itself when using sessions.

it is my experience that if you have an object and you register that object
as a session variable, and you do _not_ have a __sleep function, then
everything works fine. this is different from having a __sleep function and
not returning anything (or the wrong thing)

mike

on 8/1/01 9:32 AM, scott [gts] at [EMAIL PROTECTED] wrote:

> i added a (hopefully helpfull) addition to the
> online notes regarding magic-functions:
> http://www.php.net/manual/en/language.oop.magic-functions.php
> 
> Here's what i posted, if anyone's interested:
> 
> Here is a sample class and some test statements to
> demonstrate how __sleep() is used.
> 
> If you do not return anything from __sleep(), your
> object will *not* be serialized. You must return
> something from __sleep() to tell serialize what
> to serialize. 
> 
> <? 
> // to test the class
> $x = new Scott();
> print_r($x); 
> $y = serialize($x);
> $z = unserialize($y);
> print_r($z); 
> 
> // Simple class to test __sleep()
> class Scott { 
> // class variables
> var $error; 
> var $svar = array();
> 
> // constructor 
> function Scott() {
> $this->svar['Hello'] = "World";
> } 
> 
> function __sleep() {
> $this->svar['Hello'] = "Yawn";
> // return list of instance-variables to be serialized
> return array('error', 'svar');
> } 
> 
> function __wakeup() {
> $this->svar['test'] = "I'm here!";
> } 
> 
> }// end class 
> ?>

 -- mike cullerton



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to