【发布时间】:2014-01-18 15:33:22
【问题描述】:
我有一个运行 python 脚本的 php 脚本。我必须将 python 脚本的输出与 php 脚本中的特定常量进行比较。 我尝试使用 exec 和 popen。这是我到目前为止尝试过的代码
$out=NULL;
$pid=exec("python /home/krishna/online/createProblems.py $contest $pcode $fn1 $fn2",$out) or die("error");
if ($out=="1"){echo "Successfully inserted problem";}
并使用 popen
$pid=popen("python /home/krishna/online/createProblems.py $contest $pcode $fn1 $fn2","r") or die("error");
$ot=fread($pid,256);
if ($ot=="1"){echo "Successfully inserted problem";}
两个代码都不能正常工作...... 当我测试输出时,我得到“1”作为输出。但与“1”比较是行不通的。
【问题讨论】: