使用PHP运行c/java/python


Run c/java/python with PHP?

可能重复:
从php调用C程序并读取程序输出

我如何运行C/Java/Python/等。使用PHP时的程序?

我想您正在寻找PHPs exec函数:

exec('myapp');

使用popen()函数。这将允许您访问stdoutstdin,但只能访问其中一个。

因此,python应用程序:

$handle = popen('python /home/user/Documents/somefile.py', 'r');
var_dump(fread($handle));
pclose($handle);

但是,如果您需要同时使用stdinstdout,则应该查看proc_open()