大网数据广告活动
PHP 语言与运行手册

Lua::call · 调用Lua函数

· 52CE 我爱测

Lua::call · 调用Lua函数

Lua::call

Lua::__call

(PECL lua >=0.9.0)

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

说明

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

警告

本函数还未编写文档,仅有参数列表。

参数

lua_func

lua中的函数名。

args

向Lua函数传入的参数。

use_self

是否使用self。

返回值

返回调用函数的结果,参数错误返回null ,其它错误返回false。

示例

示例 #1 Lua::call()示例

<?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), "-")));
?>

以上示例会输出:

Lua,geiliable
Lua,geiliable
string(5) "1-2-3"

参见

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。