note 76639 added to language.oop5.magic

From: Date: Tue, 24 Jul 2007 09:08:12 +0000
Subject: note 76639 added to language.oop5.magic
Groups: php.notes 
Request: Send a blank email to php-notes+get-128860@lists.php.net to get a copy of this message
And finally, there is an issue with __sleep() and private member variables: <?php class A { private $a; public function __construct() { $this->a = 1; } } class B extends A { protected $b; public function __construct() { parent::__construct(); $this->b = 2; } function __sleep() { return array('a', 'b'); } } serialize(new B); result: Notice: serialize(): "a" returned as member variable from __sleep() but does not exist in ... This creates a serious problem, if for any reason you want to serialize an object that inherits from an external library class that has private variables. ---- Server IP: 69.147.83.197 Probable Submitter: 64.236.80.62 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.magic.php Edit -- https://master.php.net/note/edit/76639 Del: integrated -- https://master.php.net/note/delete/76639/integrated Del: useless -- https://master.php.net/note/delete/76639/useless Del: bad code -- https://master.php.net/note/delete/76639/bad+code Del: spam -- https://master.php.net/note/delete/76639/spam Del: non-english -- https://master.php.net/note/delete/76639/non-english Del: in docs -- https://master.php.net/note/delete/76639/in+docs Del: other reasons-- https://master.php.net/note/delete/76639 Reject -- https://master.php.net/note/reject/76639 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#128860) next »