Home arrow PHP arrow 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).

TABLE OF CONTENTS:
  1. Data Exchange with XML, WDDX and PHP
  2. The Wonderful World Of WDDX
  3. Polly Wants A Cracker
  4. Humbert Redfinch-Northbottom The Third, I Presume?
  5. Old Friends And New
  6. Hip To Be Square
  7. The Truth Is Out There
  8. Money Talks
  9. Closing Time
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 4
September 13, 2001

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
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");

// deserialize$original_string = wddx_deserialize($packet);

// printecho "My name is $original_string";?>
which generates the output

My name is Humbert Redfinch-Northbottom The Third
This also works with arrays - the following code

<? $star_wars = array("princess" => "Leia", "teacher" => "Yoda", "new hope" =>"Luke", "bad guy" => "Darth", "worse guy" => "The Emperor");

$packet = wddx_serialize_value($star_wars);

$data = wddx_deserialize($packet);

echo $data['princess'];?>
outputs

Leia


 
 
>>> More PHP Articles          >>> More By Vikram Vaswani, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: