是否可以 运行 PHP 孤立地编写代码?

Is it possible to run PHP code in isolation?

是否可以 运行 用户在隔离范围内提交 PHP 代码?这意味着代码将无法访问机器或 php 环境中的任何外部资源?

或者是与 javascript 一起使用并在 V8js 对象中执行它的唯一选择?

我在网上找不到好的文章。 :(

Runkit PECL 扩展中的沙箱(未嵌入 PHP)似乎能够做到这一点。 http://docs.php.net/runkit

$sandbox = new Runkit_Sandbox($options);
$sandbox->ini_set(…);
$sandbox->eval($code);

https://github.com/zenovich/runkit https://github.com/runkit7/runkit7