Revision: 229
Author: ice.shiny
Date: Wed May 16 02:38:04 2012
Log: 翻译:
macos/compile.xml;
strings/implode;
strings/lcfirst;
strings/ltrim;
strings/sprintf;
按英文版修正格式:
strings/chop;
http://code.google.com/p/phpdoc-zh/source/detail?r=229
Added:
/trunk/xml/install/macos/compile.xml
/trunk/xml/reference/strings/functions/implode.xml
/trunk/xml/reference/strings/functions/lcfirst.xml
/trunk/xml/reference/strings/functions/ltrim.xml
/trunk/xml/reference/strings/functions/sprintf.xml
Modified:
/trunk/xml/reference/strings/functions/chop.xml
=======================================
--- /dev/null
+++ /trunk/xml/install/macos/compile.xml Wed May 16 02:38:04 2012
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision: 304566 $ -->
+ <sect1 xml:id="install.macosx.compile"
xmlns="
http://docbook.org/ns/docbook"
xmlns:xlink="
http://www.w3.org/1999/xlink">
+ <title>在Mac OS X上编译PHP</title>
+ <simpara>
+ 在Mac OS X下可使用 <link linkend="install.unix">Unix下安装指南</link> 来
编译安装PHP。
+ </simpara>
+ </sect1>
+
+<!-- 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
+-->
=======================================
--- /dev/null
+++ /trunk/xml/reference/strings/functions/implode.xml Wed May 16 02:38:04
2012
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision: 301310 $ -->
+<refentry xmlns="
http://docbook.org/ns/docbook" xml:id="function.implode">
+ <refnamediv>
+ <refname>implode</refname>
+ <refpurpose>将数组元素组合为一个字符串</refpurpose>
+ </refnamediv>
+
+ <refsect1 role="description">
+ &reftitle.description;
+ <methodsynopsis>
+ <type>string</type><methodname>implode</methodname>
+
<methodparam><type>string</type><parameter>glue</parameter></methodparam>
+
<methodparam><type>array</type><parameter>pieces</parameter></methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>implode</methodname>
+
<methodparam><type>array</type><parameter>pieces</parameter></methodparam>
+ </methodsynopsis>
+ <para>
+ 用 <parameter>glue</parameter> 字符串把数组元素组合起来。
+ </para>
+ <note>
+ <para>
+ 由于历史原因,<function>implode</function> 函数能以任意顺序接受参数。但
是为了减少混乱、与
+ <function>explode</function> 函数保持一致请以文档中的顺序来使用。
+ </para>
+ </note>
+ </refsect1>
+
+ <refsect1 role="parameters">
+ &reftitle.parameters;
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><parameter>glue</parameter></term>
+ <listitem>
+ <para>
+ 默认是空字符串。但是最佳用法是将 <parameter>glue</parameter> 作为第
二个参数传递给 <function>implode</function> 。
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>pieces</parameter></term>
+ <listitem>
+ <para>
+ 字符串为元素的数组。
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <refsect1 role="returnvalues">
+ &reftitle.returnvalues;
+ <para>
+ 返回的字符串按数组中的顺序组合,参数glue字符串在每个元素之间。
+ </para>
+ </refsect1>
+
+ <refsect1 role="changelog">
+ &reftitle.changelog;
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>&Version;</entry>
+ <entry>&Description;</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>4.3.0</entry>
+ <entry>
+ <parameter>glue</parameter> 成为可选项。
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ </refsect1>
+
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example>
+ <title><function>implode</function> 示例</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$array = array('lastname', 'email', 'phone');
+$comma_separated = implode(",", $array);
+
+echo $comma_separated; // lastname,email,phone
+
+// Empty string when using an empty array:
+var_dump(implode('hello', array())); // string(0) ""
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+
+ <refsect1 role="notes">
+ &reftitle.notes;
+ ¬e.bin-safe;
+ </refsect1>
+
+ <refsect1 role="seealso">
+ &reftitle.seealso;
+ <para>
+ <simplelist>
+ <member><function>explode</function></member>
+ <member><function>preg_split</function></member>
+ </simplelist>
+ </para>
+ </refsect1>
+
+</refentry>
+
+<!-- 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
+-->
=======================================
--- /dev/null
+++ /trunk/xml/reference/strings/functions/lcfirst.xml Wed May 16 02:38:04
2012
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision: 310796 $ -->
+<refentry xmlns="
http://docbook.org/ns/docbook" xml:id="function.lcfirst">
+ <refnamediv>
+ <refname>lcfirst</refname>
+ <refpurpose>字符串的第一个字符转为小写</refpurpose>
+ </refnamediv>
+
+ <refsect1 role="description">
+ &reftitle.description;
+ <methodsynopsis>
+ <type>string</type><methodname>lcfirst</methodname>
+ <methodparam><type>string</type><parameter>str</parameter></methodparam>
+ </methodsynopsis>
+ <para>
+ 如果 <parameter>str</parameter> 的第一个字符是字母,则将其转化为小写后返
回该字符串。
+ </para>
+ <para>
+ 注意,检测是否字母取决于当前的语言环境。例如,在默认的 “C” 区域元音字符a
+ (ä) 不会被转换。
+ </para>
+ </refsect1>
+
+ <refsect1 role="parameters">
+ &reftitle.parameters;
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><parameter>str</parameter></term>
+ <listitem>
+ <para>
+ The input string.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <refsect1 role="returnvalues">
+ &reftitle.returnvalues;
+ <para>
+ 返回结果字符串。
+ </para>
+ </refsect1>
+
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example>
+ <title><function>lcfirst</function> 示例</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$foo = 'HelloWorld';
+$foo = lcfirst($foo); // helloWorld
+
+$bar = 'HELLO WORLD!';
+$bar = lcfirst($bar); // hELLO WORLD!
+$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
+
+ <refsect1 role="seealso">
+ &reftitle.seealso;
+ <para>
+ <simplelist>
+ <member><function>ucfirst</function></member>
+ <member><function>strtolower</function></member>
+ <member><function>strtoupper</function></member>
+ <member><function>ucwords</function></member>
+ </simplelist>
+ </para>
+ </refsect1>
+
+</refentry>
+
+<!-- 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
+-->
=======================================
--- /dev/null
+++ /trunk/xml/reference/strings/functions/ltrim.xml Wed May 16 02:38:04
2012
@@ -0,0 +1,201 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision: 297028 $ -->
+<refentry xmlns="
http://docbook.org/ns/docbook" xml:id="function.ltrim">
+ <refnamediv>
+ <refname>ltrim</refname>
+ <refpurpose>删除字符串开头的空格(或者其他字符)</refpurpose>
+ </refnamediv>
+
+ <refsect1 role="description">
+ &reftitle.description;
+ <methodsynopsis>
+ <type>string</type><methodname>ltrim</methodname>
+ <methodparam><type>string</type><parameter>str</parameter></methodparam>
+ <methodparam
choice="opt"><type>string</type><parameter>charlist</parameter></methodparam>
+ </methodsynopsis>
+ <para>
+ 去除字符串开头的空格(或者其他字符)。
+ </para>
+ </refsect1>
+
+ <refsect1 role="parameters">
+ &reftitle.parameters;
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><parameter>str</parameter></term>
+ <listitem>
+ <para>
+ 输入的字符串。
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>charlist</parameter></term>
+ <listitem>
+ <para>
+ 你也可以用 <parameter>charlist</parameter> 参数列出所有要删除的字
符,来指定要去除的字符。或使用
+ <literal>..</literal> 可以指定字符的范围。
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <refsect1 role="returnvalues">
+ &reftitle.returnvalues;
+ <para>
+ 函数返回了删除左侧空白的字符串。如果没有指定第二个参数,
+ <function>ltrim</function> 会删除以下字符:
+ <!-- sorted by importance. Printed 3 times: trim, ltrim, rtrim -->
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ " " (<acronym>ASCII</acronym> <literal>32</literal>
+ (<literal>0x20</literal>)),最普通的空格。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ "\t" (<acronym>ASCII</acronym> <literal>9</literal>
+ (<literal>0x09</literal>)),tab制表符。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ "\n" (<acronym>ASCII</acronym> <literal>10</literal>
+ (<literal>0x0A</literal>)),换行符。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ "\r" (<acronym>ASCII</acronym> <literal>13</literal>
+ (<literal>0x0D</literal>)),回车符。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ "\0" (<acronym>ASCII</acronym> <literal>0</literal>
+ (<literal>0x00</literal>)),空字节<literal>NUL</literal>。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara> <!-- not \v, since not supported by PHP -->
+ "\x0B" (<acronym>ASCII</acronym> <literal>11</literal>
+ (<literal>0x0B</literal>)),垂直制表符。
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </refsect1>
+
+ <refsect1 role="changelog">
+ &reftitle.changelog;
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>&Version;</entry>
+ <entry>&Description;</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>4.1.0</entry>
+ <entry>
+ 添加了 <parameter>charlist</parameter> 参数。
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ </refsect1>
+
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example>
+ <title><function>ltrim</function>使用示例</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+
+$text = "\t\tThese are a few words :) ... ";
+$binary = "\x09Example string\x0A";
+$hello = "Hello World";
+var_dump($text, $binary, $hello);
+
+print "\n";
+
+
+$trimmed = ltrim($text);
+var_dump($trimmed);
+
+$trimmed = ltrim($text, " \t.");
+var_dump($trimmed);
+
+$trimmed = ltrim($hello, "Hdle");
+var_dump($trimmed);
+
+// trim the ASCII control characters at the beginning of $binary
+// (from 0 to 31 inclusive)
+$clean = ltrim($binary, "\x00..\x1F");
+var_dump($clean);
+
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+string(32) " These are a few words :) ... "
+string(16) " Example string
+"
+string(11) "Hello World"
+
+string(30) "These are a few words :) ... "
+string(30) "These are a few words :) ... "
+string(7) "o World"
+string(15) "Example string
+"
+]]>
+ </screen>
+ </example>
+ </para>
+ </refsect1>
+
+ <refsect1 role="seealso">
+ &reftitle.seealso;
+ <para>
+ <simplelist>
+ <member><function>trim</function></member>
+ <member><function>rtrim</function></member>
+ </simplelist>
+ </para>
+ </refsect1>
+
+</refentry>
+
+<!-- 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
+-->
=======================================
--- /dev/null
+++ /trunk/xml/reference/strings/functions/sprintf.xml Wed May 16 02:38:04
2012
@@ -0,0 +1,401 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Revision: 313279 $ -->
+<refentry xmlns="
http://docbook.org/ns/docbook" xml:id="function.sprintf">
+ <refnamediv>
+ <refname>sprintf</refname>
+ <refpurpose>返回格式化后的字符串</refpurpose>
+ </refnamediv>
+
+ <refsect1 role="description">
+ &reftitle.description;
+ <methodsynopsis>
+ <type>string</type><methodname>sprintf</methodname>
+
<methodparam><type>string</type><parameter>format</parameter></methodparam>
+ <methodparam
choice="opt"><type>mixed</type><parameter>args</parameter></methodparam>
+ <methodparam
choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
+ </methodsynopsis>
+ <para>
+ 根据 <parameter>format</parameter> 字符串处理并返回字符串。
+ </para>
+ </refsect1>
+
+ <refsect1 role="parameters">
+ &reftitle.parameters;
+ <para>
+ <variablelist>
+ <varlistentry>
+ <term><parameter>format</parameter></term>
+ <listitem>
+ <para>
+ 此参数字符串由零个或多个指令组成:
+ 普通字符 (不包括 <literal>%</literal>) <emphasis>按规格转换
</emphasis> 后复制入结果,每个结果均以各自的参数转换。
+ 同时适用于 <function>sprintf</function>
+ 和 <function>printf</function>。
+ </para>
+ <para>
+ 每个转换规格由一个百分号,(<literal>%</literal>),以及以下的一个或多
个元素:
+ <orderedlist>
+ <listitem>
+ <simpara>
+ 可选的 <emphasis>符号指示符</emphasis> 强制数字使用符号(-或者
+)。默认情况下只有负数显示负号(-)。
+ 这个指示符强制正数也显示符号(+)。本特性在PHP 4.3.0中被添加。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ 可选的 <emphasis>填充指示符</emphasis> 使得字符能以正确的尺寸填充
入结果字符串。可以是一个空格也可以是 <literal>0</literal>。
+ 默认是以空格填充。也可以用单引号(<literal>'</literal>)设定填充字符。
+ 见下面的示例。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ 可选的 <emphasis>对齐方式指示符</emphasis> 设定结果应当左对齐或者
右对齐。默认是右对齐。字符“<literal>-</literal>”会使得左对齐。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ 可选的数字,<emphasis>宽度指示符</emphasis> 设定转换中使用多少字
符(最少)。
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ 可选的 <emphasis>精度指示符</emphasis> 设定浮点数应该显示几位小数
(`.')。
+ 如果在字符串上使用该指示符,实际上它按字符串长度来截断。
+ </simpara>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis>类型指定符</emphasis> 说明了参数里的数据应该是何种类
型。可能的类型有:
+ <simplelist>
+ <member>
+ <literal>%</literal> - 文字的百分号,不需要参数。
+ </member>
+ <member>
+ <literal>b</literal> - 参数作为整型(integer)以二进制形式展示。
+ </member>
+ <member>
+ <literal>c</literal> - 作为整型(integer)并显示其代表的ASCII字
符。
+ </member>
+ <member>
+ <literal>d</literal> - 将参数作为整型(integer)并显示为有符号高
精度数字(decimal)。
+ </member>
+ <member>
+ <literal>e</literal> - 参数作为科学计数法的数字 (比如 1.2e+2)。
+ PHP 5.2.1之后,精度说明符代表小数点后的位数。在更早的版本里,它
代表数字的有效位数(少了一位)。
+ </member>
+ <member>
+ <literal>E</literal> - 与 <literal>%e</literal> 类似,但是使用
大写字符(例如1.2E+2)。
+ </member>
+ <member>
+ <literal>u</literal> - 将参数作为整型(integer)并显示为无符号高
精度数字(decimal)。
+ </member>
+ <member>
+ <literal>f</literal> - 参数作为浮点,显示为浮点数(受语言环境影
响)。
+ </member>
+ <member>
+ <literal>F</literal> - 参数作为浮点,显示为浮点数(与语言环境无
关)。
+ 自PHP 4.3.10 和 PHP 5.0.3有效。
+ </member>
+ <member>
+ <literal>g</literal> - <literal>%e</literal> 和
+ <literal>%f</literal> 的简写。
+ </member>
+ <member>
+ <literal>G</literal> - <literal>%E</literal> 和
+ <literal>%f</literal> 的简写。
+ </member>
+ <member>
+ <literal>o</literal> - 参数作为整型(integer)显示成八进制数字。
+ </member>
+ <member>
+ <literal>s</literal> - 参数是字符串。
+ </member>
+ <member>
+ <literal>x</literal> - 参数作为整型(integer)并以小写字母显示成
十六进制数字。
+ </member>
+ <member>
+ <literal>X</literal> - 参数作为整型(integer)并以大写字母显示成
十六进制数字。
+ </member>
+ </simplelist>
+ </para>
+ </listitem>
+ </orderedlist>
+ </para>
+ <para>
+ 格式字符支持数字编码和替换,以下是案例:
+ <example>
+ <title>Argument swapping</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$num = 5;
+$location = 'tree';
+
+$format = 'There are %d monkeys in the %s';
+printf($format, $num, $location);
+?>
+]]>
+ </programlisting>
+ </example>
+ 会输出"There are 5 monkeys in the tree"。但是想象下,通常我们需要国
际化,所以将格式字符串放在了单独的文件里,所以写成了:
+ <example>
+ <title>Argument swapping</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$format = 'The %s contains %d monkeys';
+printf($format, $num, $location);
+?>
+]]>
+ </programlisting>
+ </example>
+ 我们现在遇上了个问题。指示符的顺序和代码中参数的调用顺序不一样。 我
们希望代码按原样而在格式字符串指定引用的参数。
+ 所以代码改成了以下格式:
+ <example>
+ <title>Argument swapping</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$format = 'The %2$s contains %1$d monkeys';
+printf($format, $num, $location);
+?>
+]]>
+ </programlisting>
+ </example>
+ 一个附加的好处是你可以在字符串中重复添加占位符,而不需要改动代码。比
例:
+ <example>
+ <title>Argument swapping</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$format = 'The %2$s contains %1$d monkeys.
+ That\'s a nice %2$s full of %1$d monkeys.';
+printf($format, $num, $location);
+?>
+]]>
+ </programlisting>
+ </example>
+ 使用参数交换时,<literal>n$</literal>
+ <emphasis>位置指示符</emphasis> 必须立刻放在百分号
(<literal>%</literal>)之后、任意字符之前。如下例所示:
+ <example>
+ <title>位置指示符和其他指示符</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$format= 'The %2$s contains %1$04d monkeys';
+printf($format, $num, $location);
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+The tree contains 0005 monkeys
+]]>
+ </screen>
+ </example>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>args</parameter></term>
+ <listitem>
+ <para>
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><parameter>...</parameter></term>
+ <listitem>
+ <para>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
+ </refsect1>
+
+ <refsect1 role="returnvalues">
+ &reftitle.returnvalues;
+ <para>
+ 返回格式化后的字符串。
+ <parameter>format</parameter>.
+ </para>
+ </refsect1>
+
+ <refsect1 role="changelog">
+ &reftitle.changelog;
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>&Version;</entry>
+ <entry>&Description;</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>4.0.6</entry>
+ <entry>
+ 添加了对参数的编号和替换。
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ </refsect1>
+
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <example>
+ <title><function>printf</function>:各个示例</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$n = 43951789;
+$u = -43951789;
+$c = 65; // ASCII 65 是 'A'
+
+// 注意两个百分号:“%%”会打印一个“%”字符
+printf("%%b = '%b'\n", $n); // 二进制形式
+printf("%%c = '%c'\n", $c); // 打印ascii字符,和chr()函数一样
+printf("%%d = '%d'\n", $n); // 最基本的整数形式
+printf("%%e = '%e'\n", $n); // 科学计数法
+printf("%%u = '%u'\n", $n); // 正整数的无符号整数形式
+printf("%%u = '%u'\n", $u); // 负数的无符号整数形式
+printf("%%f = '%f'\n", $n); // 浮点形式
+printf("%%o = '%o'\n", $n); // 八进制形式
+printf("%%s = '%s'\n", $n); // 字符串
+printf("%%x = '%x'\n", $n); // 十六进制形式(小写)
+printf("%%X = '%X'\n", $n); // 十六进制形式(大写)
+
+printf("%%+d = '%+d'\n", $n); // 正数的符号指示符
+printf("%%+d = '%+d'\n", $u); // 负数的符号指示符
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+%b = '10100111101010011010101101'
+%c = 'A'
+%d = '43951789'
+%e = '4.39518e+7'
+%u = '43951789'
+%u = '4251015507'
+%f = '43951789.000000'
+%o = '247523255'
+%s = '43951789'
+%x = '29ea6ad'
+%X = '29EA6AD'
+%+d = '+43951789'
+%+d = '-43951789'
+]]>
+ </screen>
+ </example>
+ <example>
+ <title><function>printf</function>: 字符串规格 </title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$s = 'monkey';
+$t = 'many monkeys';
+
+printf("[%s]\n", $s); // 基本字符串输出
+printf("[%10s]\n", $s); // 使用空格向右对齐
+printf("[%-10s]\n", $s); // 使用空格向左对齐
+printf("[%010s]\n", $s); // 也可以用零来对齐
+printf("[%'#10s]\n", $s); // 使用自定义的字符“#”来填充
+printf("[%10.10s]\n", $t); // 左对齐,但是在10个字符处截断
+?>
+]]>
+ </programlisting>
+ &example.outputs;
+ <screen>
+<![CDATA[
+[monkey]
+[ monkey]
+[monkey ]
+[0000monkey]
+[####monkey]
+[many monke]
+]]>
+ </screen>
+ </example>
+ <example>
+ <title><function>sprintf</function>:用零填充整数</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$isodate = sprintf("%04d-%02d-%02d", $year, $month, $day);
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title><function>sprintf</function>:货币的格式化</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$money1 = 68.75;
+$money2 = 54.35;
+$money = $money1 + $money2;
+// echo $money 会输出 "123.1";
+$formatted = sprintf("%01.2f", $money);
+// echo $formatted 会输出 "123.10"
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title><function>sprintf</function>:科学计数法</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$number = 362525200;
+
+echo sprintf("%.3e", $number); // 输出 3.625e+8
+?>
+]]>
+ </programlisting>
+ </example>
+ </refsect1>
+
+ <refsect1 role="seealso">
+ &reftitle.seealso;
+ <para>
+ <simplelist>
+ <member><function>printf</function></member>
+ <member><function>sscanf</function></member>
+ <member><function>fscanf</function></member>
+ <member><function>vsprintf</function></member>
+ <member><function>number_format</function></member>
+ </simplelist>
+ </para>
+ </refsect1>
+
+</refentry>
+
+<!-- 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
+-->
=======================================
--- /trunk/xml/reference/strings/functions/chop.xml Mon Apr 9 09:11:24 2012
+++ /trunk/xml/reference/strings/functions/chop.xml Wed May 16 02:38:04 2012
@@ -1,32 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision: 324974 $ -->
-<!-- EN-Revision: 297028 Maintainer: HonestQiao Status: ready -->
-<!-- Reviewed: no Maintainer: HonestQiao -->
-<refentry xml:id="function.chop" xmlns="
http://docbook.org/ns/docbook">
+<!-- $Revision: 297028 $ -->
+<refentry xmlns="
http://docbook.org/ns/docbook" xml:id="function.chop">
<refnamediv>
<refname>chop</refname>
- <refpurpose><function>rtrim</function> 的&Alias;</refpurpose>
+ <refpurpose>&Alias; <function>rtrim</function></refpurpose>
</refnamediv>
- <refsect1 role="description">
+
+ <refsect1 role="description">
&reftitle.description;
<simpara>
- &info.function.alias;<function>rtrim</function>。
+ &info.function.alias;
+ <function>rtrim</function>.
</simpara>
- <note>
- <para>
- <function>chop</function> 与 Perl 的
- <literal>chop()</literal> 函数有所不同,它会删除字符串的最后一个字符。
- </para>
- </note>
</refsect1>
- <refsect1 role="notes">
+ <refsect1 role="notes">
&reftitle.notes;
<note>
<para>
- <function>chop</function> is different than the Perl
- <literal>chop()</literal> function, which removes the last
- character in the string.
+ <function>chop</function> 与 Perl里只会删除字符串的最后一个字符的
+ <literal>chop()</literal> 函数有所不同。
</para>
</note>
</refsect1>