問題描述
我想從 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 代碼的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!