您也可以将函数对象作为 LuaSandboxFunction::call() 的参数传递
$lua = new LuaSandbox();
$phpLuaFunction = $lua->wrapPhpFunction(function ($arg){
echo "LUA> ".$arg;
});
$lua->loadString("print = ...")->call($phpLuaFunction);
$lua->loadString('
print("print test from lua\\n")
')->call();
结果
LUA> print test from lua