Re: visibility + unserialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux