wddx.examples.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 81 行
HTML
81 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Examples</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="wddx.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.wddx.html">WDDX Functions</a></div> <div class="up"><a href="book.wddx.html">WDDX</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Examples</h1> <div id="wddx.examples-serialize" class="section"> <p class="para"> 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. </p> <div class="example"> <p><b>Example #1 Serializing a single value with WDDX</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">wddx_serialize_value</span><span style="color: #007700">(</span><span style="color: #DD0000">"PHP to WDDX packet example"</span><span style="color: #007700">, </span><span style="color: #DD0000">"PHP packet"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p> This example will produce: </p></div> <div class="example-contents"><pre><div class="cdata"><pre><wddxPacket version='1.0'><header comment='PHP packet'/><data><string>PHP to WDDX packet example</string></data></wddxPacket></pre></div> </pre></div> </div> <div class="example"> <p><b>Example #2 Using incremental packets with WDDX</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />$pi </span><span style="color: #007700">= </span><span style="color: #0000BB">3.1415926</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$packet_id </span><span style="color: #007700">= </span><span style="color: #0000BB">wddx_packet_start</span><span style="color: #007700">(</span><span style="color: #DD0000">"PHP"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">wddx_add_vars</span><span style="color: #007700">(</span><span style="color: #0000BB">$packet_id</span><span style="color: #007700">, </span><span style="color: #DD0000">"pi"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Suppose $cities came from database */<br /></span><span style="color: #0000BB">$cities </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"Austin"</span><span style="color: #007700">, </span><span style="color: #DD0000">"Novato"</span><span style="color: #007700">, </span><span style="color: #DD0000">"Seattle"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">wddx_add_vars</span><span style="color: #007700">(</span><span style="color: #0000BB">$packet_id</span><span style="color: #007700">, </span><span style="color: #DD0000">"cities"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$packet </span><span style="color: #007700">= </span><span style="color: #0000BB">wddx_packet_end</span><span style="color: #007700">(</span><span style="color: #0000BB">$packet_id</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$packet</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> <div class="example-contents"><p> This example will produce: </p></div> <div class="example-contents"><pre><div class="cdata"><pre><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></div> </pre></div> </div> <blockquote><p><b class="note">Note</b>: If you want to serialize non-ASCII characters you have to convert your data to UTF-8 first (see <a href="function.utf8-encode.html" class="function">utf8_encode()</a> and <a href="function.iconv.html" class="function">iconv()</a>). <br /> </p></blockquote> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="wddx.constants.html">Predefined Constants</a></div> <div class="next" style="text-align: right; float: right;"><a href="ref.wddx.html">WDDX Functions</a></div> <div class="up"><a href="book.wddx.html">WDDX</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?