PHP - Lua::call() __call()



Lua::call -- Lua::__call — 调用 Lua 函数

语法

public mixed Lua::call( callable $lua_func [, array $args [, int $use_self = 0 ]] )
public mixed Lua::__call( callable $lua_func [, array $args [, int $use_self = 0 ]] )

Lua::call -- Lua::__call 函数可以返回被调用函数的结果,对于错误的参数返回 NULL,或者在失败时返回 false。

示例

<?php
   $lua = new Lua();
   $lua->eval(
      <<<CODE
      function dummy(foo, bar)
         print(foo, ",", bar)
      end
      CODE
   );
   $lua->call("dummy", array("Lua", "geiliable\n"));
   $lua->dummy("Lua", "geiliable");   // __call()
   
   var_dump($lua->call(array("table", "concat"), array(array(1=>1, 2=>2, 3=>3), "-")));
?>
php_function_reference.htm
广告