WDDX FunctionsWDDX
These functions are intended for work with WDDX.
In order to use WDDX, you will need to install the expat library
(which comes with apache 1.3.7 or higher) and recompile PHP with
and .
Note that all the functions that serialize variables use the first
element of an array to determine whether the array is to be
serialized into an array or structure. If the first element has
string key, then it is serialized into a structure, otherwise,
into an array.
Serializing a single value
]]>
This example will produce:
PHP to WDDX packet example
]]>
Using incremental packets
]]>
This example will produce:
3.1415926AustinNovatoSeattle
]]>
wddx_serialize_valueSerialize a single value into a WDDX packetDescriptionstring
wddx_serialize_valuemixed varstring
commentwddx_serialize_value is used to create a
WDDX packet from a single given value. It takes the value
contained in var, and an optional
comment string that appears in the packet
header, and returns the WDDX packet.
wddx_serialize_varsSerialize variables into a WDDX packetDescriptionstring wddx_serialize_varsmixed var_namemixed
...wddx_serialize_vars is used to create a WDDX
packet with a structure that contains the serialized
representation of the passed variables.
wddx_serialize_vars takes a variable number
of arguments, each of which can be either a string naming a
variable or an array containing strings naming the variables or
another array, etc.
wddx_serialize_vars example
]]>
The above example will produce:
15.5blueorangevioletcolors
]]>
wddx_packet_start
Starts a new WDDX packet with structure inside it
Descriptionint wddx_packet_startstring
comment
Use wddx_packet_start to start a new WDDX
packet for incremental addition of variables. It takes an
optional comment string and returns a
packet ID for use in later functions. It automatically creates a
structure definition inside the packet to contain the variables.
wddx_packet_endEnds a WDDX packet with the specified IDDescriptionstring wddx_packet_endint packet_idwddx_packet_end ends the WDDX packet
specified by the packet_id and returns the
string with the packet.
wddx_add_vars
Add variables to a WDDX packet with the specified ID
Descriptionwddx_add_varsint packet_idmixed name_varmixed
...wddx_add_vars is used to serialize passed
variables and add the result to the packet specified by the
packet_id. The variables to be serialized
are specified in exactly the same way as
wddx_serialize_vars.
wddx_deserializeDeserializes a WDDX packetDescriptionmixed wddx_deserializestring packetwddx_deserialize takes a
packet string and deserializes it. It
returns the result which can be string, number, or array. Note
that structures are deserialized into associative arrays.