<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Invokes function</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reflectionfunction.getclosure.html">ReflectionFunction::getClosure</a></div> <div class="next" style="text-align: right; float: right;"><a href="reflectionfunction.invokeargs.html">ReflectionFunction::invokeArgs</a></div> <div class="up"><a href="class.reflectionfunction.html">ReflectionFunction</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="reflectionfunction.invoke" class="refentry"> <div class="refnamediv"> <h1 class="refname">ReflectionFunction::invoke</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">ReflectionFunction::invoke</span> — <span class="dc-title">Invokes function</span></p> </div> <div class="refsect1 description" id="refsect1-reflectionfunction.invoke-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>ReflectionFunction::invoke</strong></span> ([ <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$parameter</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$...</code></span> ]] )</div> <p class="para rdfs-comment"> Invokes a reflected function. </p> </div> <div class="refsect1 parameters" id="refsect1-reflectionfunction.invoke-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">args</code></em></span> <dd> <p class="para"> The passed in argument list. It accepts a variable number of arguments which are passed to the function much like <span class="function"><a href="function.call-user-func.html" class="function">call_user_func()</a></span> is. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-reflectionfunction.invoke-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the result of the invoked function call. </p> </div> <div class="refsect1 examples" id="refsect1-reflectionfunction.invoke-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-5224"> <p><strong>Example #1 <span class="methodname"><strong>ReflectionFunction::invoke()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">title</span><span style="color: #007700">(</span><span style="color: #0000BB">$title</span><span style="color: #007700">, </span><span style="color: #0000BB">$name</span><span style="color: #007700">)<br />{<br /> return </span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s. %s\r\n"</span><span style="color: #007700">, </span><span style="color: #0000BB">$title</span><span style="color: #007700">, </span><span style="color: #0000BB">$name</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$function </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'title'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$function</span><span style="color: #007700">-></span><span style="color: #0000BB">invoke</span><span style="color: #007700">(</span><span style="color: #DD0000">'Dr'</span><span style="color: #007700">, </span><span style="color: #DD0000">'Phil'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> Dr. Phil </pre></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-reflectionfunction.invoke-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> If the function has arguments that need to be references, then they must be references in the passed argument list. </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-reflectionfunction.invoke-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="reflectionfunction.export.html" class="methodname" rel="rdfs-seeAlso">ReflectionFunction::export()</a> - Exports function</span></li> <li class="member"><a href="language.oop5.magic.html#object.invoke" class="link">__invoke()</a></li> <li class="member"> <span class="function"><a href="function.call-user-func.html" class="function" rel="rdfs-seeAlso">call_user_func()</a> - Call the callback given by the first parameter</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reflectionfunction.getclosure.html">ReflectionFunction::getClosure</a></div> <div class="next" style="text-align: right; float: right;"><a href="reflectionfunction.invokeargs.html">ReflectionFunction::invokeArgs</a></div> <div class="up"><a href="class.reflectionfunction.html">ReflectionFunction</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>