<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionmethod.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'reflectionmethod.invokeargs.php',
    1 => 'ReflectionMethod::invokeArgs',
    2 => '带参数执行',
  ),
  'up' => 
  array (
    0 => 'class.reflectionmethod.php',
    1 => 'ReflectionMethod',
  ),
  'prev' => 
  array (
    0 => 'reflectionmethod.invoke.php',
    1 => 'ReflectionMethod::invoke',
  ),
  'next' => 
  array (
    0 => 'reflectionmethod.isabstract.php',
    1 => 'ReflectionMethod::isAbstract',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/reflection/reflectionmethod/invokeargs.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionmethod.invokeargs" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionMethod::invokeArgs</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionMethod::invokeArgs</span> &mdash; <span class="dc-title">带参数执行</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionmethod.invokeargs-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionMethod::invokeArgs</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.object.php" class="type object">object</a></span></span> <code class="parameter">$object</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$args</code></span>): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   使用数组给方法传送参数，并执行他。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionmethod.invokeargs-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">object</code></dt>
     <dd>
      <p class="para">
       调用方法的对象，如果是静态对象，设置为 <span class="type"><a href="language.types.null.php" class="type null">null</a></span>
      </p>
     </dd>
    
    
     <dt><code class="parameter">args</code></dt>
     <dd>
      <p class="para">
       使用 <span class="type"><a href="language.types.array.php" class="type array">array</a></span> 传送的方法参数。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionmethod.invokeargs-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回方法返回值。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-reflectionmethod.invokeargs-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   如果 <code class="parameter">object</code> 指定的实例无法执行方法，那么产生
   <span class="classname"><a href="class.reflectionexception.php" class="classname">ReflectionException</a></span> 异常。
  </p>
  <p class="para">
   如果方法调用失败，产生 <span class="classname"><a href="class.reflectionexception.php" class="classname">ReflectionException</a></span>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-reflectionmethod.invokeargs-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        <code class="parameter">args</code> 的键现在将解释为参数的名称，而不是默默忽略。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionmethod.invokeargs-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="methodname"><strong>ReflectionMethod::invokeArgs()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">HelloWorld </span><span style="color: #007700">{<br /><br />    public function </span><span style="color: #0000BB">sayHelloTo</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">) {<br />        return </span><span style="color: #DD0000">'Hello ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$name</span><span style="color: #007700">;<br />    }<br /><br />}<br /><br /></span><span style="color: #0000BB">$reflectionMethod </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionMethod</span><span style="color: #007700">(</span><span style="color: #DD0000">'HelloWorld'</span><span style="color: #007700">, </span><span style="color: #DD0000">'sayHelloTo'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$reflectionMethod</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">invokeArgs</span><span style="color: #007700">(new </span><span style="color: #0000BB">HelloWorld</span><span style="color: #007700">(), array(</span><span style="color: #DD0000">'Mike'</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="annotation-interactive examplescode"><pre class="examplescode">Hello Mike</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-reflectionmethod.invokeargs-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    如果函数有参数需为引用，那么它们必须以引用方式传入。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionmethod.invokeargs-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionmethod.invoke.php" class="methodname" rel="rdfs-seeAlso">ReflectionMethod::invoke()</a> - Invoke</span></li>
    <li><a href="language.oop5.magic.php#object.invoke" class="link">__invoke()</a></li>
    <li><span class="function"><a href="function.call-user-func-array.php" class="function" rel="rdfs-seeAlso">call_user_func_array()</a> - 调用回调函数，并把一个数组参数作为回调函数的参数</span></li>
   </ul>
  </p>
 </div>


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