array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'luasandbox.registerlibrary.php', 1 => 'LuaSandbox::registerLibrary', ), 'up' => array ( 0 => 'class.luasandbox.php', 1 => 'LuaSandbox', ), 'prev' => array ( 0 => 'luasandbox.pauseusagetimer.php', 1 => 'LuaSandbox::pauseUsageTimer', ), 'next' => array ( 0 => 'luasandbox.setcpulimit.php', 1 => 'LuaSandbox::setCPULimit', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/luasandbox/luasandbox/registerlibrary.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PECL luasandbox >= 1.0.0)
LuaSandbox::registerLibrary — Register a set of PHP functions as a Lua library
Registers a set of PHP functions as a Lua library, so that Lua can call the relevant PHP code.
For more information about calling Lua functions and the return values, see LuaSandboxFunction::call().
Hiçbir değer dönmez.
Örnek 1 Registering PHP functions to call from Lua
<?php
// create a new LuaSandbox
$sandbox = new LuaSandbox();
// Register some functions in the Lua environment
function frobnosticate( $v ) {
return [ $v + 42 ];
}
$sandbox->registerLibrary( 'php', [
'frobnosticate' => 'frobnosticate',
'output' => function ( $string ) {
echo "$string\n";
},
'error' => function () {
throw new LuaSandboxRuntimeError( "Something is wrong" );
}
] );
?>