array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'tr', ), 'this' => array ( 0 => 'luasandbox.loadstring.php', 1 => 'LuaSandbox::loadString', 2 => 'Load Lua code into the Lua environment', ), 'up' => array ( 0 => 'class.luasandbox.php', 1 => 'LuaSandbox', ), 'prev' => array ( 0 => 'luasandbox.loadbinary.php', 1 => 'LuaSandbox::loadBinary', ), 'next' => array ( 0 => 'luasandbox.pauseusagetimer.php', 1 => 'LuaSandbox::pauseUsageTimer', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/luasandbox/luasandbox/loadstring.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PECL luasandbox >= 1.0.0)
LuaSandbox::loadString — Load Lua code into the Lua environment
Loads Lua code into the Lua environment.
This is the equivalent of standard Lua's loadstring() function.
codechunkNameReturns a LuaSandboxFunction which, when executed, will execute the passed $code.
Örnek 1 Loading code into Lua
<?php
// create a new LuaSandbox
$sandbox = new LuaSandbox();
// Load the code
$function = $sandbox->loadString(
<<<CODE
return "Hello, world"
CODE
);
// Execute the loaded code
var_dump( $function->call() );
?>Yukarıdaki örneğin çıktısı:
array(1) {
[0]=>
string(12) "Hello, world"
}