December 2001
Intermediate to advanced
520 pages
13h 42m
English
Because of the unique nature of objects, they cannot be as easily managed as strings or numbers. This makes them more difficult to store in a database, pass along to a second PHP script, or set as a cookie. To handle such issues, PHP has the serialize() function, which takes a variable and turns it into a more manageable version of itself. It works like so:
$variable = serialize ($object);
To return the serialized variable back into its standard form, use the unserialize() function.
$object = unserialize ($variable);
The only caveat to using these two functions with objects is that the page that unserializes the variable must have access to the class definitions.
As a crude analogy, say you had created a really cool toy ...
Read now
Unlock full access