Re: visibility + unserialization
| From: | Chris | Date: | Tue, 27 May 2008 00:56:12 +0000 |
| Subject: | Re: visibility + unserialization | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-274708@lists.php.net to get a copy of this message | ||
Ted Wood wrote:
>
> I have a 4 year old framework that serializes objects and stores them in
> the database. It is now going PHP 5-only, so I began to add visibility
> to the class definitions of the serialized objects. However, then things
> didn't work properly after objects stored [before the visibility was
> added] were unserialized. For example, each protected field ended up
> creating two fields, with one followed by ":protected".
I don't see two fields, I only see one:
$ php -a
Interactive mode enabled
<?php
class abc {
protected $x = '21345';
function __construct() {}
}
$x = new abc();
echo serialize($x);
O:3:"abc":1:{s:4:"*x";s:5:"21345";}
$y = serialize($x);
print_r(unserialize($y));
abc Object
(
[x:protected] => 21345
)
As for why they come out like that, no idea - I couldn't find any
comments on php.net about it either.
--
Postgresql & php tutorials
http://www.designmagick.com/