mirror of
https://github.com/php/doc-ja.git
synced 2026-03-23 22:52:11 +01:00
- Move utf8_encode and utf8_decode into the strings chapter, since
they were moved out of the XML extension in 7.2
- Recommend mb_convert_encoding, iconv, and UConverter::transcode
when mentioning encoding in passing
- Document UConverter::transcode, based on examination of source
and upstream ICU docs
- Make the language used more consistent, e.g. "convert" rather
than "encode"/"decode", "encoding" rather than "charset"
99d758bd25
102 lines
2.9 KiB
XML
102 lines
2.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 99d758bd259fa80c2828cf8cc250984cb683ee8f Maintainer: takagi Status: ready -->
|
|
<!-- CREDITS: hirokawa -->
|
|
|
|
<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>wddx の例</title>
|
|
<para>
|
|
変数をシリアル化する全ての関数は配列の最初要素をその配列が配列と
|
|
構造体のどちらでシリアル化されるのかを定義するために使用するということに
|
|
注意してください。最初の要素が文字列をキーとして有する場合は
|
|
構造体でシリアル化され、その他の場合は配列でシリアル化されます。
|
|
</para>
|
|
|
|
<example>
|
|
<title>WDDX を使用した単一の値のシリアル化</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo wddx_serialize_value("PHP to WDDX packet example", "PHP packet");
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
この例は次の出力を行います。
|
|
</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>WDDX を使用してパケットを追加する例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$pi = 3.1415926;
|
|
$packet_id = wddx_packet_start("PHP");
|
|
wddx_add_vars($packet_id, "pi");
|
|
|
|
/* $cities はデータベースから取得するものと仮定します */
|
|
$cities = array("Austin", "Novato", "Seattle");
|
|
wddx_add_vars($packet_id, "cities");
|
|
|
|
$packet = wddx_packet_end($packet_id);
|
|
echo $packet;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
この例は次のような出力を行います。
|
|
</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>
|
|
文字列は UTF-8 でエンコードされているべきです。
|
|
つまり、他のエンコーディングを扱うには、
|
|
文字列をはじめに
|
|
<function>mb_convert_encoding</function> や
|
|
<methodname>UConverter::transcode</methodname>,
|
|
<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
|
|
-->
|
|
|
|
|