No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

LuaSandbox::loadString

(PECL luasandbox >= 1.0.0)

LuaSandbox::loadStringLoad Lua code into the Lua environment

Description

public LuaSandbox::loadString(string $code, string $chunkName = ''): LuaSandboxFunction

Loads Lua code into the Lua environment.

This is the equivalent of standard Lua's loadstring() function.

PHP: LuaSandbox::loadString - Manual Home of Manuel PHP  Contents Haut

Parameters

code

Lua code.

chunkName

Name for the loaded chunk, for use in error traces.

PHP: LuaSandbox::loadString - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns a LuaSandboxFunction which, when executed, will execute the passed $code.

PHP: LuaSandbox::loadString - Manual Home of Manuel PHP  Contents Haut

Examples

Example #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() );

?>

The above example will output:

array(1) {
  [0]=>
  string(12) "Hello, world"
}

PHP: LuaSandbox::loadString - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function
Error Infobrol

Can not display this page of the Infobrol website

Type of error (18-01)

Unknown format specifier "&"

Please try again in a few minutes…

Return to the home page




Steph