【问题标题】:PHP popen() path with quotesPHP popen() 带引号的路径
【发布时间】:2013-02-12 12:22:40
【问题描述】:

我正在尝试在 Windows 中使用 PHP 的 popen() 函数运行 exe 文件。一切都很完美,除非我的 .exe 文件的路径中有空格。 所以这行得通:

popen("start /b D:\\test.exe", r);

这不是:

popen("start /b D:\\path with space\\test.exe", r);

通常在 CMD 中,当您想要这样做时,只需将路径放在引号中,例如:“D:\path with space\test.exe”,这适用于 exec() 函数,但不适用于 popen()。

我试过了:

popen('start /b "D:\\path with space\\test.exe"', r);

但它不起作用。

有人知道怎么做吗?

【问题讨论】:

  • 你的 PHP 版本是多少?

标签: php popen


【解决方案1】:

使用escapeshellarg() 函数添加空格。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 2012-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多