php shell_exec 返回 null

Mas*_*ari 5 php command cmd shell-exec

我想php ../cat1/index.php gr_s2/3/gr-n40 1200通过 php 运行命令。shell_exec 返回 NULL 作为结果,但是当我在 cmd 上尝试该命令时,输出显示正确。

php 和 shell_exec 中发生了什么?

注意:具有不同参数的命令(例如:)php ../cat1/index.php gr_s2/3/gr-n40 800在(php 和 cmd)中都可以正常工作。

sho*_*deh 3

shell_execute的 php 手册页中有一条注释

注意:当发生错误或程序没有输出时,该函数可能返回 NULL。使用此函数无法检测执行失败。当需要访问程序退出代码时,应使用 exec()。

来源: http: //php.net/manual/en/function.shell-exec.php

所以你的代码运行时出错。尝试使用exec。如果需要,请插入要检查的代码(或块)。