I was wondering if anyone could point me to a resource where the details of a serialized php string is documented. I would basically like to know the format/structure so I can write a function in VB.NET to serialize/deserialize it back.
Thanks!
I was wondering if anyone could point me to a resource where the details of a serialized php string is documented. I would basically like to know the format/structure so I can write a function in VB.NET to serialize/deserialize it back.
Thanks!
The basic structure is as follows:
Scalar types:
Booleans are serialized as:
where
<i>
is an integer with a value of either0
(false) or1
(true).Integers are serialized as:
where
<i>
is the integer value.Floats are serialized as (with
d
meaning double):where
<f>
is the float value.Strings are serialized as:
where
<i>
is an integer representing the string length of<s>
, and<s>
is the string value.Special types:
null
is simply serialized as:Compound types:
Arrays are serialized as:
where
<i>
is an integer representing the number of elements in the array, and<elements>
zero or more serialized key value pairs:where
<key>
represents a serialized scalar type, and<value>
any value that is serializable.Objects are serialized as:
where the first
<i>
is an integer representing the string length of<s>
, and<s>
is the fully qualified class name (class name prepended with full namespace). The second<i>
is an integer representing the number of object properties.<properties>
are zero or more serialized name value pairs:where
<name>
is a serialized string representing the property name, and<value>
any value that is serializable.There's a catch with
<name>
though:<name>
is represented aswhere
<i>
is an integer representing the string length of<s>
. But the values of<s>
differs per visibility of properties:a. With public properties
<s>
is the simple name of the property.b. With protected properties, however,
<s>
is the simple name of the property, prepended with