WDDX Functions WDDX 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.1415926 AustinNovato Seattle ]]> wddx_serialize_value Serialize a single value into a WDDX packet Description string wddx_serialize_value mixed var string comment wddx_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_vars Serialize variables into a WDDX packet Description string wddx_serialize_vars mixed var_name mixed ... 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:
1 5.5 blueorangeviolet colors ]]> wddx_packet_start Starts a new WDDX packet with structure inside it Description int wddx_packet_start string 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_end Ends a WDDX packet with the specified ID Description string wddx_packet_end int packet_id wddx_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 Description wddx_add_vars int packet_id mixed name_var mixed ... 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_deserialize Deserializes a WDDX packet Description mixed wddx_deserialize string packet wddx_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.