我怎样才能使我的网站 运行 在我的服务器上成为一个大型 C 程序并 return 输出到客户端?
How can I make my website run a large C program on my server and return the output to the client?
我希望能够获取用户输入,运行 我的服务器上基于该输入的程序,以及 return 以文件形式输出到客户端。我不知道该怎么做。如果我使用的是 WAMP 解决方案堆栈,我是否需要在我的 PHP 代码中有一个函数调用 windows 脚本并让该函数处理与我的程序的交互?这是最好的方法吗?这可能吗?
像这样的东西是你想要做的事情的一个很好的框架
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=savethis.txt");
$command = null;
switch($_GET["input"])
{
case "list":
if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN")
{
$command = "dir";
}
else
{
$command = "ls";
}
default:
// do nothing
break;
}
if (!is_null($command))
{
$output = shell_exec($command);
echo $output;
}
我希望能够获取用户输入,运行 我的服务器上基于该输入的程序,以及 return 以文件形式输出到客户端。我不知道该怎么做。如果我使用的是 WAMP 解决方案堆栈,我是否需要在我的 PHP 代码中有一个函数调用 windows 脚本并让该函数处理与我的程序的交互?这是最好的方法吗?这可能吗?
像这样的东西是你想要做的事情的一个很好的框架
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename=savethis.txt");
$command = null;
switch($_GET["input"])
{
case "list":
if (strtoupper(substr(PHP_OS, 0, 3)) === "WIN")
{
$command = "dir";
}
else
{
$command = "ls";
}
default:
// do nothing
break;
}
if (!is_null($command))
{
$output = shell_exec($command);
echo $output;
}