Skip to content

Commit

Permalink
function.arguments: Remove explanation of legacy variadics
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Oct 23, 2023
1 parent 6f07432 commit 724c2dc
Showing 1 changed file with 1 addition and 50 deletions.
51 changes: 1 addition & 50 deletions language/functions.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: 1f8a9bbeec69c16c4b965c350525baf5744b8f4e Maintainer: avenger Status: ready -->
<!-- EN-Revision: b22f4a798a435fb159af88806341ce9cbe9f38c2 Maintainer: avenger Status: ready -->
<!-- CREDITS: Gregory, dallas, Luffy, mowangjuanzi -->
<chapter xml:id="language.functions" xmlns="http://docbook.org/ns/docbook">
<title>函数</title>
Expand Down Expand Up @@ -437,16 +437,6 @@ Making a bowl of raspberry natural yogurt.
<literal>...</literal> 语法实现。
</simpara>

<note>
<simpara>
还可以使用以下函数来获取可变参数
<function>func_num_args</function>、
<function>func_get_arg</function> 和
<function>func_get_args</function>,不建议使用此方式,请使用
<literal>...</literal> 来替代。
</simpara>
</note>

<para>
包含 <literal>...</literal>
的参数,会转换为指定参数变量的一个 &array;
Expand Down Expand Up @@ -559,45 +549,6 @@ Catchable fatal error: Argument 2 passed to total_intervals() must be an instanc
<literal>...</literal> 前加上一个 (<literal>&amp;</literal>) 符号来实现。
</para>

<sect3 xml:id="functions.variable-arg-list.old">
<title>旧版本的 PHP</title>

<para>
不需要特殊的语法来声明一个函数是可变的;但是访问函数的参数必须使用
<function>func_num_args</function>, <function>func_get_arg</function>
和 <function>func_get_args</function> 函数。
</para>

<para>
上面的第一个例子在早期 PHP 版本中的实现如下:

<example>
<title>在 PHP 早期版本中访问可变参数</title>
<programlisting role="php">
<![CDATA[
<?php
function sum() {
$acc = 0;
foreach (func_get_args() as $n) {
$acc += $n;
}
return $acc;
}
echo sum(1, 2, 3, 4);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
10
]]>
</screen>
</example>
</para>
</sect3>

</sect2>

<sect2 xml:id="functions.named-arguments">
Expand Down

0 comments on commit 724c2dc

Please sign in to comment.