faqts : Computers : Programming : Languages : PHP : kms : Classes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

3 of 5 people (60%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

How can I serialize a class in PHP?

Jun 28th, 1999 00:54
Nathan Wallace, Nathan Wallace


Take a look at the serialization code in PHPLIB:
    http://phplib.shonline.de

The basic idea is to add two variables to every class:
    classname
    persistent_slots

The classname is what is says, persistent_slots is an array of the names
of the variables that need to be stored and retrieved when the class is
serialized.

If each class has these variables then a single serialize function can
be used to handle any object.