WDDX 为全球信息网分散式文件交换,全名为 Web Distributed Data Exchange。其实
WDDX 可以算是 XML 的一个分支。更多有关 WDDX 的信息可以参考 http://www.wddx.org。
例一: 本例将单一值连续化
<?php print wddx_serialize_value("PHP to WDDX packet example", "PHP packet"); ?>
返回到浏览器的资料为
<wddxPacket version='0.9'><header comment='PHP packet'/><data>
<string>PHP to WDDX packet example</string></data></wddxPacket>
例二: 本例将 WDDX 封包加入资料
<?php $pi = 3.1415926; $packet_id = wddx_packet_start("PHP"); wddx_add_vars($packet_id, "pi");
/* Suppose $cities came from database */ $cities = array("Austin", "Novato", "Seattle"); wddx_add_vars($packet_id, "cities");
$packet = wddx_packet_end($packet_id); print htmlentities($packet); ?>
返回到浏览器的资料为
<wddxPacket version='0.9'><header comment='PHP'/><data><struct>
<var name='pi'><number>3.1415926</number></var><var name='cities'>
<array length='3'><string>Austin</string><string>Novato</string>
<string>Seattle</string></array></var></struct></data></wddxPacket>
|