Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13516 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11710 invoked by uid 1010); 26 Oct 2004 07:10:12 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 11593 invoked from network); 26 Oct 2004 07:10:11 -0000 Received: from unknown (HELO mail.gmx.net) (213.165.64.20) by pb1.pair.com with SMTP; 26 Oct 2004 07:10:11 -0000 Received: (qmail 25040 invoked by uid 65534); 26 Oct 2004 07:10:11 -0000 Received: from 55.Red-213-4-20.pooles.rima-tde.net (EHLO [10.10.0.21]) (213.4.20.55) by mail.gmx.net (mp020) with SMTP; 26 Oct 2004 09:10:11 +0200 X-Authenticated: #12441595 Message-ID: <417DF8B8.4000203@gmx.net> Date: Tue, 26 Oct 2004 09:11:52 +0200 User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derick Rethans CC: internals References: <417CE408.4020108@gmx.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Convert an array in an object instance From: fmmarzoa@gmx.net ("Francisco M. Marzoa Alonso") 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 php-general@lists.php.net mailinglist for user support >questions, this is the wrong list. > >Derick > > >