need inverted __sleep?
| From: | Nathan Rixham | Date: | Mon, 01 Jun 2009 01:04:26 +0000 |
| Subject: | need inverted __sleep? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-44106@lists.php.net to get a copy of this message | ||
Hi All,
hoping somebody can help me here..
I need to implement an inverted __sleep method, by which I mean to specify what variables should not be included.
use case:
<?php
class base
{
private $notToBeSerialized;
public function __sleep()
{
// TODO code return instance properties excluding $notToBeSerialized} } class foo extends base { private $bar; } class poo extends foo { private $baz; } $p = new poo; echo serialize($p); ---- I've tried using get_object_vars($this), and ReflectionObject($this) both of which don't include all the properties of the instance. the only way I can see to get all the properties of the instance is to serialize($this) then parse the string, but that's just wrong and what would sleep return on the first call to serialize. any help greatly appreciated. regards, nathan