我想从php执行一个php脚本,它将使用不同的常量和已经定义的不同版本的类.
是否有沙箱php_module我可以:
sandbox('script.php'); // run in a new php environment
Run Code Online (Sandbox Code Playgroud)
代替
include('script.php'); // run in the same environment
Run Code Online (Sandbox Code Playgroud)
或者proc_open()是唯一的选择吗?
PS:无法通过网络访问该脚本,因此fopen(' http://host/script.php ')不是一个选项.
从外部来源我得到的字符串就像
array(1,2,3)
Run Code Online (Sandbox Code Playgroud)
但也有更大的阵列
array("a", "b", "c", array("1", "2", array("A", "B")), array("3", "4"), "d")
Run Code Online (Sandbox Code Playgroud)
我需要它们是php中的实际数组.我知道我可以使用eval,但由于它是不受信任的来源,我宁愿不这样做.我也无法控制外部资源.
我应该为此使用一些正则表达式(如果是这样,是什么)还是有其他方法?