Lua::registerCallback
PHP function
Edit on GitHub ✎
Register a PHP function to Lua
Description
Lua::registerCallback(string $name, callable $function): mixed
Register a PHP function to Lua as a function named "$name"
Parameters
namefunctionA valid PHP function callback
Return Values
Returns $this, null for wrong arguments or false on other failure.
Examples
Lua::registerCallback()example
php
<?php
$lua = new Lua();
$lua->registerCallback("echo", "var_dump");
$lua->eval(<<<CODE
echo({1, 2, 3});
CODE
);
?>The above example will output:
output
array(3) {
[1]=>
float(1)
[2]=>
float(2)
[3]=>
float(3)
}