mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-24 08:52:09 +01:00
100 lines
2.8 KiB
XML
100 lines
2.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 99d758bd259fa80c2828cf8cc250984cb683ee8f Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<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>Exemples wddx</title>
|
|
<para>
|
|
Toutes les fonctions qui sérialisent les variables utilisent
|
|
le premier élément d'un tableau pour déterminer si le tableau
|
|
doit être sérialisé dans un tableau ou dans une structure.
|
|
Si le premier élément a une chaîne de caractères en tant que
|
|
clé, alors, il sera sérialisé dans une structure, sinon, dans
|
|
un tableau.
|
|
</para>
|
|
|
|
<example>
|
|
<title>Sérialisation d'une valeur simple avec WDDX</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo wddx_serialize_value("PHP to WDDX packet example", "PHP packet");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Cet exemple affichera :
|
|
</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>Utilisation de paquets incrémentaux avec WDDX</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$pi = 3.1415926;
|
|
$packet_id = wddx_packet_start("PHP");
|
|
wddx_add_vars($packet_id, "pi");
|
|
|
|
/* Suppose que $cities provient d'une base de données */
|
|
$cities = array("Austin", "Novato", "Seattle");
|
|
wddx_add_vars($packet_id, "cities");
|
|
|
|
$packet = wddx_packet_end($packet_id);
|
|
echo $packet;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
Cet exemple affichera :
|
|
</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>
|
|
Les chaînes de caractères doivent être encodées en UTF-8 ; pour gérer d'autres encodages,
|
|
convertissez d'abord la chaîne de caractères en utilisant la <function>mb_convert_encoding</function>,
|
|
<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
|
|
-->
|
|
|
|
|