<!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>Call Lua functions</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="lua.assign.html">Lua::assign</a></div> <div class="next" style="text-align: right; float: right;"><a href="lua.construct.html">Lua::__construct</a></div> <div class="up"><a href="class.lua.html">Lua</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="lua.call" class="refentry"> <div class="refnamediv"> <h1 class="refname">Lua::call</h1> <h1 class="refname">Lua::__call</h1> <p class="verinfo">(PECL lua >=0.9.0)</p><p class="refpurpose"><span class="refname">Lua::call</span> -- <span class="refname">Lua::__call</span> — <span class="dc-title">Call Lua functions</span></p> </div> <div class="refsect1 description" id="refsect1-lua.call-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>Lua::call</strong></span> ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$lua_func</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$use_self</code><span class="initializer"> = 0</span></span> ]] )</div> <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>Lua::__call</strong></span> ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$lua_func</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$args</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$use_self</code><span class="initializer"> = 0</span></span> ]] )</div> <p class="para rdfs-comment"> </p> <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This function is currently not documented; only its argument list is available. </p></div> </div> <div class="refsect1 parameters" id="refsect1-lua.call-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <span class="term"><em><code class="parameter">lua_func</code></em></span> <dd> <p class="para"> Function name in lua </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">args</code></em></span> <dd> <p class="para"> Arguments passed to the Lua function </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">use_self</code></em></span> <dd> <p class="para"> Whether to use <em>self</em> </p> </dd> </dt> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-lua.call-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns result of the called function, <strong><code>NULL</code></strong> for wrong arguments or <strong><code>FALSE</code></strong> on other failure. </p> </div> <div class="refsect1 examples" id="refsect1-lua.call-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-3767"> <p><strong>Example #1 <span class="function"><strong>Lua::call()</strong></span>example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$lua </span><span style="color: #007700">= new </span><span style="color: #0000BB">Lua</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-></span><span style="color: #0000BB">eval</span><span style="color: #007700">(<<<CODE<br /></span><span style="color: #DD0000"> function dummy(foo, bar)<br /> print(foo, ",", bar)<br /> end<br /></span><span style="color: #007700">CODE<br />);<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-></span><span style="color: #0000BB">call</span><span style="color: #007700">(</span><span style="color: #DD0000">"dummy"</span><span style="color: #007700">, array(</span><span style="color: #DD0000">"Lua"</span><span style="color: #007700">, </span><span style="color: #DD0000">"geiliable\n"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$lua</span><span style="color: #007700">-></span><span style="color: #0000BB">dummy</span><span style="color: #007700">(</span><span style="color: #DD0000">"Lua"</span><span style="color: #007700">, </span><span style="color: #DD0000">"geiliable"</span><span style="color: #007700">); </span><span style="color: #FF8000">// __call()<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$lua</span><span style="color: #007700">-></span><span style="color: #0000BB">call</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"table"</span><span style="color: #007700">, </span><span style="color: #DD0000">"concat"</span><span style="color: #007700">), array(array(</span><span style="color: #0000BB">1</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">2</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">=></span><span style="color: #0000BB">3</span><span style="color: #007700">), </span><span style="color: #DD0000">"-"</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> Lua,geiliable Lua,geiliable string(5) "1-2-3" </pre></div> </div> </div> </div> <div class="refsect1 seealso" id="refsect1-lua.call-seealso"> <h3 class="title">See Also</h3> <ul class="simplelist"> <li class="member"><a href="language.oop5.overloading.html#object.call" class="link">__call()</a></li> </ul> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="lua.assign.html">Lua::assign</a></div> <div class="next" style="text-align: right; float: right;"><a href="lua.construct.html">Lua::__construct</a></div> <div class="up"><a href="class.lua.html">Lua</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>