PHP 8.1.0 Beta 1 available for testing


(PECL luasandbox >= 1.0.0)

LuaSandbox::setMemoryLimitSet the memory limit for the Lua environment


public LuaSandbox::setMemoryLimit ( int $limit ) : void

Sets the memory limit for the Lua environment.

If this limit is exceeded, a LuaSandboxMemoryError exception is thrown.



Memory limit in bytes.

Valorile întoarse

Nu este întoarsă nici o valoare.


Example #1 Calling a Lua function


// create a new LuaSandbox
$sandbox = new LuaSandbox();

// set a memory limit
$sandbox->setMemoryLimit50 1024 1024 );

// Run Lua code
$sandbox->loadString'local x = "x"; while true do x = x .. x; end' )->call();


Exemplul de mai sus va afișa ceva similar cu:

PHP Fatal error:  Uncaught LuaSandboxMemoryError: not enough memory

A se vedea și

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top