Is there a way to execute php code in a sandbox from within php(有没有办法在 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() 是唯一的选择吗?
Or is proc_open() the only option?
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 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有办法在 php 中的沙箱中执行 php 代码


基础教程推荐
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 使用 PDO 转义列名 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01