|
Posted by Justin Koivisto on 01/24/06 21:49
Carl Vondrick wrote:
> You can "store" objects in an array, sure:
>
> $my_array = array(new my_object(), new_my_object());
>
> That should work just fine (untested).
>
> You can also try and serialize objects, which are useful if you want to
> save them after execution is over. To do this, you use serialize()and
> unserialize(). For example:
>
> fwrite($handle, serialize($myobject));
>
> Then later on:
>
> $a = unserialize(file_get_contents('serialized_code.php'));
Be sure that you have included the class definitions *before* you
attempt to unserialize an object, or you may have some problems.
I haven't tried serializing objects in php, but I was just thinking that
in php5 because of the pass by reference default nature, you may have
difficulty with it if you aren't using the clone keyword...
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|