Skip to content

Commit

Permalink
Update strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mowangjuanzi committed Jan 13, 2025
1 parent 7206d26 commit befa5f1
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 45 deletions.
2 changes: 1 addition & 1 deletion reference/strings/functions/count-chars.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: e095023e408c8cb6378ae16bb6870343a3946919 Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: eb3c7d0d67625bae5fad478f5e11eebb71b397c8 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.count-chars" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down
10 changes: 4 additions & 6 deletions reference/strings/functions/echo.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 7a3899eea90f3df8dcfe8fd350900162f3490bed Maintainer: daijie Status: ready -->
<!-- EN-Revision: 2a5223230bf6177c225003ca30c63f48ef266cc0 Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.echo">
<refnamediv>
Expand Down Expand Up @@ -127,10 +127,8 @@ echo $some_var ? 'true': 'false'; // 首先运行表达式然后传递它到 ech
使用括号括住 <literal>echo</literal>
后的单个参数并不会引发语法错误,而且还会产生看起来像普通函数调用的语法。但是,这可能会产生误导,因为括号实际上是输出表达式的一部分,而不是
<literal>echo</literal> 语法本身的一部分。
</para>
<para>
<example>
<title/>

<informalexample>
<programlisting role="php">
<![CDATA[
<?php
Expand All @@ -155,7 +153,7 @@ echo("hello", " world");
?>
]]>
</programlisting>
</example>
</informalexample>
</para>
</note>

Expand Down
18 changes: 12 additions & 6 deletions reference/strings/functions/htmlentities.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 840ed22479a110ab63bce0fa75d5f3c41642b8e3 Maintainer: daijie Status: ready -->
<!-- EN-Revision: 06394ea77c2f8972e3884c00bede861ef5eb04da Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.htmlentities" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -184,20 +184,26 @@
&reftitle.examples;
<para>
<example>
<title><function>htmlentities</function> 例子</title>
<title><function>htmlentities</function> 示例</title>
<programlisting role="php">
<![CDATA[
<?php
$str = "A 'quote' is <b>bold</b>";
// 输出: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str);
// 输出: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
echo htmlentities($str, ENT_QUOTES);
echo "\n\n";
echo htmlentities($str, ENT_COMPAT);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
A 'quote' is &lt;b&gt;bold&lt;/b&gt
]]>
</screen>
</example>
</para>

Expand Down
36 changes: 34 additions & 2 deletions reference/strings/functions/number-format.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: de35b538453a7817a0cc839cddda0be46eed8764 Maintainer: daijie Status: ready -->
<!-- EN-Revision: ae148826a6830492a51e47f21e1ad4f80373f2a6 Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.number-format" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
Expand Down Expand Up @@ -38,7 +38,9 @@
<term><parameter>decimals</parameter></term>
<listitem>
<para>
设置小数位数。如果为 <literal>0</literal>,则从返回值中忽略 <parameter>decimal_separator</parameter>。
设置小数位数。如果为 <literal>0</literal>,则从返回值中忽略 <parameter>decimal_separator</parameter>。自
PHP 8.3.0 起,当值为负数时,<parameter>num</parameter> 将四舍五入为小数点前的有效数字
<parameter>decimals</parameter>。在 PHP 8.3.0 之前,负值将被忽略并与 <literal>0</literal> 一样处理。
</para>
</listitem>
</varlistentry>
Expand Down Expand Up @@ -81,6 +83,12 @@
</row>
</thead>
<tbody>
<row>
<entry>8.3.0</entry>
<entry>
新增对 <parameter>decimals</parameter> 负值的处理。
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Expand Down Expand Up @@ -133,6 +141,30 @@ $english_format_number = number_format($number, 2, '.', '');
</programlisting>
</example>
</para>
<example>
<title><parameter>decimals</parameter> 为负值</title>
<simpara>
自 PHP 8.3.0 起,使用 <parameter>decimals</parameter> 的负值来对小数点前的有效数字的位数进行四舍五入。
</simpara>
<programlisting role="php">
<![CDATA[
<?php
$number = "1234.5678";
var_dump(number_format($number, -1));
var_dump(number_format($number, -2));
var_dump(number_format($number, -3));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
string(5) "1,230"
string(5) "1,200"
string(5) "1,000"
]]>
</screen>
</example>
</refsect1>

<refsect1 role="seealso">
Expand Down
17 changes: 6 additions & 11 deletions reference/strings/functions/print.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 7a3899eea90f3df8dcfe8fd350900162f3490bed Maintainer: daijie Status: ready -->
<!-- EN-Revision: 2a5223230bf6177c225003ca30c63f48ef266cc0 Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.print">
<refnamediv>
Expand Down Expand Up @@ -105,10 +105,8 @@ if ( print "hello" ) {
用括号括住 <literal>print</literal>
的参数并不会引发语法错误,而且会产生看起来像是普通函数调用的语法。然而,这可能会产生误导,因为括号实际上是输出表达式的一部分,而非
<literal>print</literal> 语法本身的一部分。
</para>
<para>
<example>
<title/>

<informalexample>
<programlisting role="php">
<![CDATA[
<?php
Expand All @@ -135,16 +133,13 @@ else {
?>
]]>
</programlisting>
</example>
</informalexample>
</para>

<para>
当在大表达式中使用 <literal>print</literal> 时,需要将关键字及其参数放在括号中以便得出预期的结果:
</para>

<para>
<example>
<title/>
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
Expand All @@ -169,7 +164,7 @@ print "hello " && print "world";
?>
]]>
</programlisting>
</example>
</informalexample>
</para>
</note>

Expand Down
8 changes: 4 additions & 4 deletions reference/strings/functions/str-split.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: e1621b408bdd443153611090847023aa39829bb0 Maintainer: daijie Status: ready -->
<!-- EN-Revision: 31e301590744e91ee5903f3e20973ddb9f3dadbb Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.str-split" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down Expand Up @@ -146,9 +146,8 @@ Array
&reftitle.notes;
<note>
<para>
在处理多字节字符时,<function>str_split</function>
会按字节数转换,而非字符数。使用 <function>mb_str_split</function>
将字符串拆分为码点。
处理多字节编码字符串时,<function>str_split</function> 将拆分为字节,而不是字符。<function>mb_str_split</function>
可用于将字符串拆分为码点。<function>grapheme_str_split</function> 可用于将字符串拆分为字素簇。
</para>
</note>
</refsect1>
Expand All @@ -158,6 +157,7 @@ Array
<para>
<simplelist>
<member><function>mb_str_split</function></member>
<member><function>grapheme_str_split</function></member>
<member><function>chunk_split</function></member>
<member><function>preg_split</function></member>
<member><function>explode</function></member>
Expand Down
33 changes: 19 additions & 14 deletions reference/strings/functions/strcspn.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 422bb032237525aaf50e6a43f33362a2c610a1d7 Maintainer: daijie Status: ready -->
<!-- EN-Revision: 89990d6588947665d4e9c029ee83696f1a9d3d11 Maintainer: daijie Status: ready -->
<!-- CREDITS: mowangjuanzi -->
<refentry xml:id="function.strcspn" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>strcspn</refname>
Expand Down Expand Up @@ -92,9 +93,7 @@
</para>
<note>
<para>
When a <parameter>offset</parameter> parameter is set, the returned length
is counted starting from this position, not from the beginning of
<parameter>string</parameter>.
当设置了 <parameter>offset</parameter> 参数时,返回的长度是从该位置开始计算,而不是从 <parameter>string</parameter> 的开头计算。
</para>
</note>
</refsect1>
Expand All @@ -110,6 +109,15 @@
</row>
</thead>
<tbody>
<row>
<entry>8.4.0</entry>
<entry>
<simpara>
在 PHP 8.4.0 之前,当 <parameter>characters</parameter> 为空字符串时,搜索会错误地停止在
<parameter>string</parameter> 的第一个 null 字节处。
</simpara>
</entry>
</row>
<row>
<entry>8.0.0</entry>
<entry>
Expand All @@ -128,29 +136,26 @@
<programlisting role="php">
<![CDATA[
<?php
$a = strcspn('abcd', 'apple');
$b = strcspn('abcd', 'banana');
$c = strcspn('hello', 'l');
$d = strcspn('hello', 'world');
$e = strcspn('abcdhelloabcd', 'abcd', -9);
$f = strcspn('abcdhelloabcd', 'abcd', -9, -5);
$a = strcspn('banana', 'a');
$b = strcspn('banana', 'abcd');
$c = strcspn('banana', 'z');
$d = strcspn('abcdhelloabcd', 'a', -9);
$e = strcspn('abcdhelloabcd', 'a', -9, -5);
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
var_dump($e);
var_dump($f);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
int(1)
int(0)
int(0)
int(2)
int(2)
int(6)
int(5)
int(4)
]]>
Expand Down
2 changes: 1 addition & 1 deletion reference/var/functions/unserialize.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 42bb18bcfef4f715008d00bbdc7ea5203f8ec30a Maintainer: HonestQiao Status: ready -->
<!-- EN-Revision: d75036c386e37ce56dafb7607b72aedc3e33fe09 Maintainer: HonestQiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<refentry xml:id="function.unserialize" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
Expand Down

0 comments on commit befa5f1

Please sign in to comment.