Serializing is a nice way to get a string out of more complicated data structure. It's probably mostly used to sting-alize array data, although you can serialize scalar data as well.
The result of the serialization is no nature wonder, it's just a string that describes what is serialized and a value of the serialized ... thing.
The cert guide explains it all very well, I think just maybe an example of how something looks when it's serialized would have been nice. Otherwise the serialization may sound scary and mysterious.
Here's an example:
$s = 'PHP';
- 's' is a string, the type of the serialized var
- '3' is the length
- 'PHP' is the value
- ';' is a delimiter
A slightly more complicated example - serializing an array:
$ar = array('PHP','key'=>'serialize');
The result is:
- 'a' means an array
- 'i' as in integer
- 'i:0' is the integer key of the first element of the array, remember when you don't specify a key, PHP assigns one
This entry was posted on Tuesday, March 29th, 2005 and is filed under PHP certification. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.