note 43641 added to function.serialize

From: Date: Mon, 28 Jun 2004 22:57:48 +0000
Subject: note 43641 added to function.serialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-72080@lists.php.net to get a copy of this message
If there is good documentation for __sleep() and __wakeup(), I haven't found it. It looks like (after some trial and error) you have to return $this from __sleep(), or your data will go missing. An example: <?php class strawman { function __sleep() { print "Function __sleep() called\n"; return $this; /* The missing ingredient */ } function __wakeup() { print "Function __wakeup() called\n"; } function strawman() { } } session_start(); if(session_is_registered('strawman')) { print("session data:\n"); print_r($_SESSION['strawman']); session_destroy(); } else { $strawman =& new strawman(); session_register('strawman'); print("new session data:\n"); print_r($_SESSION['strawman']); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.serialize.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43641 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43641&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43641&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72080) next »