<HTML ><HEAD ><TITLE >WDDX Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="w32api_set_call_method" HREF="function.w32api-set-call-method.html"><LINK REL="NEXT" TITLE="wddx_add_vars" HREF="function.wddx-add-vars.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.w32api-set-call-method.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.wddx-add-vars.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.wddx" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >CVI. WDDX Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN95248" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.intro" ></A >Introduction</H1 ><P > These functions are intended for work with <A HREF="http://www.openwddx.org/" TARGET="_top" >WDDX</A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.requirements" ></A >Requirements</H1 ><P > In order to use WDDX, you will need to install the expat library (which comes with Apache 1.3.7 or higher). </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.installation" ></A >Installation</H1 ><P > After installing expat compile PHP with <TT CLASS="option" >--enable-wddx</TT >. </P ><P > The windows version of <TT CLASS="literal" >PHP</TT > has built in support for this extension. You do not need to load any additional extension in order to use these functions.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.configuration" ></A >Runtime Configuration</H1 ><P >This extension has no configuration directives defined in <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.resources" ></A >Resource Types</H1 ><P >This extension has no resource types defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.constants" ></A >Predefined Constants</H1 ><P >This extension has no constants defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="wddx.examples" ></A >Examples</H1 ><P > 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. <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN95275" ></A ><P ><B >Example 1. Serializing a single value</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php print wddx_serialize_value("PHP to WDDX packet example", "PHP packet"); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > This example will produce: <DIV CLASS="informalexample" ><A NAME="AEN95279" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><wddxPacket version='1.0'><header comment='PHP packet'/><data> <string>PHP to WDDX packet example</string></data></wddxPacket></PRE ></TD ></TR ></TABLE ><P ></P ></DIV > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN95281" ></A ><P ><B >Example 2. Using incremental packets</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?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 $packet; ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > This example will produce: <DIV CLASS="informalexample" ><A NAME="AEN95285" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" ><wddxPacket version='1.0'><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></PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > If you want to serialize non-ASCII characters you have to set the appropriate locale before doing so (see <A HREF="function.setlocale.html" ><B CLASS="function" >setlocale()</B ></A >). </P ></BLOCKQUOTE ></DIV ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.wddx-add-vars.html" >wddx_add_vars</A > -- Add variables to a WDDX packet with the specified ID </DT ><DT ><A HREF="function.wddx-deserialize.html" >wddx_deserialize</A > -- Deserializes a WDDX packet</DT ><DT ><A HREF="function.wddx-packet-end.html" >wddx_packet_end</A > -- Ends a WDDX packet with the specified ID</DT ><DT ><A HREF="function.wddx-packet-start.html" >wddx_packet_start</A > -- Starts a new WDDX packet with structure inside it </DT ><DT ><A HREF="function.wddx-serialize-value.html" >wddx_serialize_value</A > -- Serialize a single value into a WDDX packet</DT ><DT ><A HREF="function.wddx-serialize-vars.html" >wddx_serialize_vars</A > -- Serialize variables into a WDDX packet</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.w32api-set-call-method.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.wddx-add-vars.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >w32api_set_call_method</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >wddx_add_vars</TD ></TR ></TABLE ></DIV ></BODY ></HTML >