note 43664 added to function.serialize

From: Date: Tue, 29 Jun 2004 19:02:36 +0000
Subject: note 43664 added to function.serialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-72121@lists.php.net to get a copy of this message
Correction to my last note: __sleep should return an array only containing the names of instance-variables to serialize. A simple (if not a little wasteful) hack to serialize all but a few class vars is to use get_class_vars as follows: <?php class strawman { var $good_var; var $lame_var; function __sleep() { print "Function __sleep() called\n"; $vars = get_class_vars('strawman'); unset($vars['lame_var']); return array_keys($vars); } 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+43664 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43664&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43664&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#72121) next »