PHP Manual
Prev |  | Next

# LV. WDDX functions

These functions are intended for work with WDDX.

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.

Example 1. Serializing a single value

      1
      2 <?php
      3 print wddx_serialize_value("PHP to WDDX packet example", "PHP packet");
      4 ?>
      5

This example will produce:

      1
      2 <wddxPacket version='0.9'><header comment='PHP packet'/><data>
      3 <string>PHP to WDDX packet example</string></data></wddxPacket>
      4

Example 2. Using incremental packets

      1
      2 <?php
      3 $pi = 3.1415926;
      4 $packet_id = wddx_packet_start("PHP");
      5 wddx_add_vars($packet_id, "pi");
      6
      7 /* Suppose $cities came from database */
      8 $cities = array("Austin", "Novato", "Seattle");
      9 wddx_add_vars($packet_id, "cities");
     10
     11 $packet = wddx_packet_end($packet_id);
     12 print $packet;
     13 ?>
     14

This example will produce:

      1
      2 <wddxPacket version='0.9'><header comment='PHP'/><data><struct>
      3 <var name='pi'><number>3.1415926</number></var><var name='cities'>
      4 <array length='3'><string>Austin</string><string>Novato</string>
      5 <string>Seattle</string></array></var></struct></data></wddxPacket>
      6

Prev | Home | Next
vm_deluser | Up | wddx_serialize_value