gpt4 book ai didi

php shell_exec 返回空值

转载 作者:行者123 更新时间:2023-12-01 13:47:41 27 4
gpt4 key购买 nike

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

在 php 和 shell_exec 中发生了什么?!

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

最佳答案

shell_execute 的 php 手册页中有一个注释:

Note: This function can return NULL both when an error occurs or the program produces no output. It is not possible to detect execution failures using this function. exec() should be used when access to the program exit code is required.

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

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

关于php shell_exec 返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34628827/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com