pienez Posted April 7, 2008 Share Posted April 7, 2008 Hello, I am having a little trouble. I just want to ask some help in understanding php. this is my problem. I made my own class Day private $ID; private $date; private $startinghour private $endinghour; private $startplace; private $endplace; with ofcorse getters and setters. no other functions. now I want to fill up an array with my own class. I want to have a list of Days. than I want to put that in an $_SESSION['days'] and use it on an other page. what is the best way to do that? I saw something like serializable, is it that what I am looking for? thx in advance Link to comment https://forums.phpfreaks.com/topic/99969-array-with-own-objects/ Share on other sites More sharing options...
Cep Posted April 7, 2008 Share Posted April 7, 2008 serialize($array) will serialise the data for your session and then you can unserialize to get it out. This action is automatically performed if your php.ini is set up that way but your class is going to need __wakeup() and __sleep() magic methods so the objects come out of the session correctly. Link to comment https://forums.phpfreaks.com/topic/99969-array-with-own-objects/#findComment-511205 Share on other sites More sharing options...
pienez Posted April 7, 2008 Author Share Posted April 7, 2008 is serialize the only way to use my class in an array? Link to comment https://forums.phpfreaks.com/topic/99969-array-with-own-objects/#findComment-511209 Share on other sites More sharing options...
Cep Posted April 7, 2008 Share Posted April 7, 2008 No its the only way to store the object in a database or session. As far as I am aware you can use an active array to transport objects but only an active array (meaning your script does not try to pass it to another script). Link to comment https://forums.phpfreaks.com/topic/99969-array-with-own-objects/#findComment-511213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.