在PHP中运行C ++脚本 [英] Run C++ script in PHP

查看:143
本文介绍了在PHP中运行C ++脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++程序,需要从PHP脚本中获取数据,处理它,并将数据返回到我的PHP脚本。


  1. 如何将值从PHP传递到C ++?

  2. 如何运行C ++脚本?

  3. 如何从C ++脚本中获取值?


<



> 回答: 在php文件中,您可以使用 exec 函数来执行你的C ++二进制文件。
示例:

  exec(/ path / to / your / binary $ var1 $ var2,$ output) ; 

2。如何运行C ++脚本?

当然,你不能执行C ++脚本直接,C ++是编译语言,你只需执行二进制文件。



3。 C ++脚本?



回答:请参阅1,您将获得C ++的输出形式 $ output


I have a C++ program that needs to take data from a PHP script, process it, and return the data to my PHP script.

  1. How do you pass the values from PHP to C++?
  2. How do you run the C++ script? Do you have to compile it first some how?
  3. How do you get the values out of the C++ script?

解决方案

1 . How do you pass the values from PHP to C++?

Ans: In php file, you could use exec function to execute your C++ binary file. Example:

exec("/path/to/your/binary $var1 $var2", $output);

2 . How do you run the C++ script? Do you have to compile it first some how?

Ans: Of course, you can't execute the C++ script directly, C++ is compiled language, you could just execute the binary file.

3 . How do you get the values out of the C++ script?

Ans: See 1, you will get the output form C++ by $output.

这篇关于在PHP中运行C ++脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆