Dutch PHP Conference 2026 - Call For Papers

The LuaSandboxFunction class

(PECL luasandbox >= 1.0.0)

Einführung

Represents a Lua function, allowing it to be called from PHP.

A LuaSandboxFunction may be obtained as a return value from Lua, as a parameter passed to a callback from Lua, or by using LuaSandbox::wrapPhpFunction() , LuaSandbox::loadString() , or LuaSandbox::loadBinary() .

Klassenbeschreibung

class LuaSandboxFunction {
/* Methoden */
public call (string ...$args): array |bool
public dump (): string
}

Inhaltsverzeichnis

Found A Problem?

Learn How To Improve This PageSubmit a Pull RequestReport a Bug
+add a note

User Contributed Notes 1 note

up
1
npelov at croler dot net
1 year ago
You can also pass function object as argument of 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();

result:
LUA> print test from lua
+add a note

AltStyle によって変換されたページ (->オリジナル) /