I am having a problem with __sleep();
there mere existance of it is causing my object
to not get serialized at all.  __wakeup() works fine.

i am using PHP v4.0.6 / apache / win2k.

If i keep __sleep() in the object, it will not serialize,
but if i remove it, it serialized fine.  Does anyone
know why this happens?

Here's my object:

class Scott {
  var $svar = array();  // free-form hash for whatever data
  function Scott( )
  {
        return $this;
  }
  function __sleep() 
  {
  }
  function __wakeup() 
  {
        $this->svar['sleep'] = "I am waking up";
  }
}// end class


and now a test script

require_once('class.Scott.php');

$scott = new Scott();
$scott->svar['blah'] = "bacon";

print "object = ". $scott ."\n";
print "blah = ". $scott->svar['blah'] ."\n";
print "\n";

// serialize
$ser = serialize($scott);
print "serialized = ". $ser ."\n";

// trash the object
unset($scott);
print "unset object = ". $scott ."\n\n";

// unserialize
$scott = unserialize($ser);
print "object = ". $scott ."\n";
print "blah = ". $scott->svar['blah'] ."\n";
print "sleep = ". $scott->svar['sleep'] ."\n";


-- 
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