php8.5
Home/ Manual/ lua / lua/ Lua::eval

Lua::eval

PHP function Edit on GitHub ✎

(PECL lua >=0.9.0)

Evaluate a string as Lua code

Description

Lua::eval(string $statements): mixed

Func

Parameters

statements

Return Values

Returns result of evaled code, null for wrong arguments or false on other failure.

Examples

Lua::eval()example

php
<?php
$lua = new Lua();
$lua->eval(<<<CODE
    print(2);
CODE
);
?>

The above example will output:

output
2

Source: reference/lua/lua/eval.xml · from the official PHP manual (php/doc-en)