Jump to content

Array with own objects


pienez

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.