有没有一种方法可以从php内部在沙箱中执行php代码 [英] Is there a way to execute php code in a sandbox from within php

查看:55
本文介绍了有没有一种方法可以从php内部在沙箱中执行php代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从php执行一个php脚本,该脚本将使用不同的常量和已经定义的类的不同版本.

I want to execute a php-script from php that will use different constants and different versions of classes that are already defined.

是否有一个我可以使用的沙箱php_module:

Is there a sandbox php_module where i could just:

sandbox('script.php'); // run in a new php environment

代替

include('script.php'); // run in the same environment

还是 proc_open()唯一的选择?

PS:无法通过网络访问该脚本,因此请使用fopen(' http://host/script.php ')是不可选项.

PS: The script isn't accessible through the web, so fopen('http://host/script.php') is not an option.

推荐答案

runkit ,但是您如果您不这样做,可能会发现仅通过命令行调用脚本会更简单(使用 shell_exec )需要主进程和子进程之间的任何交互.

There is runkit, but you may find it simpler to just call the script over the command line (Use shell_exec), if you don't need any interaction between the master and child processes.

这篇关于有没有一种方法可以从php内部在沙箱中执行php代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆