HomePHP Page 4 - Data Exchange with XML, WDDX and PHP
Humbert Redfinch-Northbottom The Third, I Presume? - PHP
You may never have heard of it before - but if your job involvesexchanging data between different servers and applications, you're going tobe hearing a lot about it very soon. Find out how WDDX makes it possible tocreate and transmit platform-neutral data structures across the Web, andhow it can be combined with PHP to create a whole new generation of Webapplications (including new content syndication and financial updateservices).
The process of converting a data structure into WDDX is referred to as "serialization". Deserialization is, obviously, the reverse process. And your favourite language and mine, PHP, comes with a number of WDDX functions to accomplish both these (although you may need to recompile your PHP build to enable them.)
The first of these is the wddx_serialize_value() function, used to create a WDDX packet containing a single value. The function also accepts an optional second parameter, which is used to generate a comment for the packet. So the following line of code
<?
echo wddx_serialize_value("Humbert Redfinch-Northbottom The Third", "Who da
man?");
?>
would generate the WDDX fragment
<wddxPacket version='1.0'>
<header><comment>Who da man?</comment></header><data><string>Humbert Redfinch-Northbottom The Third</string></data></wddxPacket>
Once a value has been serialized, it can be reconstituted into its original form with the wddx_deserialize() function, used to convert a WDDX packet into a native data structure. Consider the following example,
<?
// serialize$packet = wddx_serialize_value("Humbert Redfinch-Northbottom The Third");