【发布时间】:2015-03-24 12:03:16
【问题描述】:
我想写一个后台任务。所以我写了一个基本的脚本来查看shell_exec的工作脚本如下:
<?php
$op = shell_exec("php -v");
echo $op;
echo "back to the test.php";
?>
输出应该是 php 版本信息,但它会打印以下意外输出:
back to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.phpback to the test.php
它打印我当前页面内容 59-60 次,有时使用 content-type:text/html 我尝试使用另一个 php 文件输出是相同的
然后我尝试了像 date 这样的 linux 命令,它可以完美运行 请帮我解决这个我无法弄清楚问题所在的问题?
我也尝试了 php 的绝对路径,但没有区别,并且还使用了其他 php 函数,如 system、exec 等。
编辑说明:我已将 exec 函数更改为 shell_exec,因为我放错了位置。下面显示的输出来自 shell_exec
更新 我没有得到问题的解决方案,但得到了问题的原因,脚本中没有任何问题,这是因为服务器。我已经写信给服务器的支持中心,但没有得到回复所以我认为这个问题已经结束了
【问题讨论】:
标签: php exec background-process shell-exec