php shell_exec 返回空值

标签 php cmd command shell-exec

我想通过 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/

相关文章:

c++ - 在 VIM 中删除一个完整的函数

c# - WPF - DataGrid 不应处理 Ctrl+A

javascript - 如果在前端发生付款时数据库出错怎么办

java - 从命令行读取输出

macos - 如何在没有 android studio 的情况下在 Mac M1 上启动 Android Emulator

c# - 如何从 C# 使用 CHKDSK 工具并在 CMD 窗口中显示文本?

windows - XCOPY:在 BATCH 中无提示地覆盖所有

php - 无法在magento中查看订单

php - Python 像 PHP 一样设置错误报告级别

php - 第二个 WordPress 循环失败