note 83517 deleted from language.oop.magic-functions by danbrown

From: Date: Sat, 07 Nov 2009 18:54:51 +0000
Subject: note 83517 deleted from language.oop.magic-functions by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162502@lists.php.net to get a copy of this message
Note Submitter: matthes at leuffen dot de ---- To serialize private or protected properties, you need to add the classname to the name of the property (otherwise serialize() will return empty properties): <?php // Works: class SerializeMe { private $myPrivateProperty; public function __sleep () { return array ("\0".__CLASS__."\0"."myPrivateProperty"); } } ?> It looks stupid: Without any __sleep() method private Properties are serialized as well as protected and public. But if you add a __sleep() method, they won't. This may help you saving some hours of googleing ;-)

« previous php.notes (#162502) next »