Sorry, I've ask this question on general but no one seems to know if there's a solution for it. In fact, its possible to do something as:

$MyObject = new MyClass ();
$MyArray = (array) $MyObject;
$MyObject2 = (object) $MyArray;

But the original class of the object is lost -$MyObject2 appears as an instance of stdClass instead MyClass-. This wouldn't be a problem if there were a manner to tell PHP that $MyObject2 is a MyClass instance after the last line, but I didn't find a way to do that.

In Perl there's a function that's called 'bless' that servers for this purpouse:
http://www.emerson.emory.edu/services/perl/perldoc/manual/perlfunc/bless.html


But I didn't found an equivalent in PHP.

I'm writting my own serialization routines and I need this to unserialize objects.

Thx.



Derick Rethans wrote:

On Mon, 25 Oct 2004, Francisco M. Marzoa Alonso wrote:



Hi,

Is it possible to convert an array in an object instance?



Please use the [EMAIL PROTECTED] mailinglist for user support questions, this is the wrong list.

Derick




-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to