将输入传递给 C 程序并使用 php 获取输出

发布于 2025-01-04 13:26:47 字数 234 浏览 2 评论 0原文

我正在开发一个项目,我编写了两个 C 程序,将日期和时间转换为分钟,然后再转换回来。我想要做的是将 php 变量传递给 C 程序,然后让 C 程序将结果返回给 php 中的变量。

我意识到您可以使用 popen 或 exec 命令,但我不确定如何使用这些命令。

我将如何构建 php 代码? 我必须在 C 程序中使用哪些输入和输出命令?如果你们能给我举几个例子那就太好了。我从例子中学得更好。

提前致谢。

I am working on a project and I wrote two C programs that convert date and time into minutes and then back. What I want to do is pass a php variable into a C program and then have the C program return the result to a variable in php.

I realize that you can use popen or exec commands but I am unsure how to use these commands.

How would I structure the php code?
What input and output commands would I have to use in the C program? If you guys could give me a few examples that would be great. I learn better from examples.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2025-01-11 13:26:47
$cmd = "/path/to/prog " . escapeshellarg($something);
$c_output = shell_exec($cmd);
$cmd = "/path/to/prog " . escapeshellarg($something);
$c_output = shell_exec($cmd);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文