WDDX 函数库
时间:2007-02-17 来源:PHP爱好者
例一: 本例将单一值连续化
<?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
php爱好者站 http://www.phpfans.net 文章|教程|下载|源码|论坛.