mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
* updates to reference/shmop due to revisions in english * updates to reference/sockets due to revisions in english * updates to reference/wddx due to revisions in english
98 lines
2.7 KiB
XML
98 lines
2.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 99d758bd259fa80c2828cf8cc250984cb683ee8f Maintainer: leonardolara Status: ready --><!-- CREDITS: felipe,leonardolara -->
|
|
|
|
<chapter xml:id="wddx.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
<section xml:id="wddx.examples-serialize">
|
|
<title>Exemplos de wddx</title>
|
|
<para>
|
|
Todas as funções que serializam variáveis usam o primeiro
|
|
elemento de um array para determinar se o array deve ser
|
|
serializado em um array ou estrutura. Se o primeiro elemento
|
|
tem uma chave string, então ele é serializado em uma estrutura, caso contrário,
|
|
em um array.
|
|
</para>
|
|
|
|
<example>
|
|
<title>Serializando um único valor com WDDX</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo wddx_serialize_value("PHP to WDDX packet example", "PHP packet");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Este exemplo irá produzir:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
<wddxPacket version='1.0'><header comment='PHP packet'/><data>
|
|
<string>PHP to WDDX packet example</string></data></wddxPacket>
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<example>
|
|
<title>Usando pacotes incrementais com WDDX</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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);
|
|
echo $packet;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Este exemplo irá produzir:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
<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>
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
|
|
<note>
|
|
<para>
|
|
Strings devem ser codificadas em UTF-8; para lidar com outras codificações, converta
|
|
a string primeiramente usando <function>mb_convert_encoding</function>, você tem que primeiro
|
|
<methodname>UConverter::transcode</methodname> ou <function>iconv</function>.
|
|
</para>
|
|
</note>
|
|
</section>
|
|
</chapter>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|
|
|
|
|