<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.funchand.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.func-num-args.php',
    1 => 'func_num_args',
    2 => '返回传递给函数的参数数量',
  ),
  'up' => 
  array (
    0 => 'ref.funchand.php',
    1 => '函数处理 函数',
  ),
  'prev' => 
  array (
    0 => 'function.func-get-args.php',
    1 => 'func_get_args',
  ),
  'next' => 
  array (
    0 => 'function.function-exists.php',
    1 => 'function_exists',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/funchand/functions/func-num-args.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.func-num-args" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">func_num_args</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">func_num_args</span> &mdash; <span class="dc-title">返回传递给函数的参数数量</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.func-num-args-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>func_num_args</strong></span>(): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   获取传递给函数的参数数量。
  </p>
  <p class="para">
   此函数可以与 <span class="function"><a href="function.func-get-arg.php" class="function">func_get_arg()</a></span> 和 <span class="function"><a href="function.func-get-args.php" class="function">func_get_args()</a></span>
   结合使用，以便于允许用户定义的函数可以接受可变长度的参数列表。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.func-num-args-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.func-num-args-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回传递给当前用户定义函数的参数数量。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.func-num-args-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果从用户定义的函数外部调用，则生成警告。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.func-num-args-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>func_num_args()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">foo</span><span style="color: #007700">()<br />{<br />    echo </span><span style="color: #DD0000">"Number of arguments: "</span><span style="color: #007700">, </span><span style="color: #0000BB">func_num_args</span><span style="color: #007700">(), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">);   <br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Number of arguments: 3</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.func-num-args-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para">As of PHP 8.0.0, the func_*() family of
functions is intended to be mostly transparent with regard to named arguments,
by treating the arguments as if they were all passed positionally,
and missing arguments are replaced with their defaults.
This function ignores the collection of unknown named variadic arguments.
Unknown named arguments which are collected can only be accessed through the variadic parameter.</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.func-num-args-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="functions.arguments.php#functions.variable-arg-list" class="link"><code class="literal">...</code> 语法</a></li>
    <li><span class="function"><a href="function.func-get-arg.php" class="function" rel="rdfs-seeAlso">func_get_arg()</a> - 返回参数列表的某一项</span></li>
    <li><span class="function"><a href="function.func-get-args.php" class="function" rel="rdfs-seeAlso">func_get_args()</a> - 返回一个包含函数参数列表的数组</span></li>
    <li><span class="methodname"><a href="reflectionfunctionabstract.getnumberofparameters.php" class="methodname" rel="rdfs-seeAlso">ReflectionFunctionAbstract::getNumberOfParameters()</a> - 获取参数数目</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>