Php exec - 不能使用参数

Php exec - not work with parameters

我需要使用 exec() 函数,但它不适用于参数。

有效:

exec('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe');

它没有:

exec('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --headless --disable-gpu --screenshot=D:\file211.png --window-size=1920,1200 http://google.com')

如何设置 exec 中的参数?

http://php.net/manual/en/function.exec.php:

Note: On Windows exec() will first start cmd.exe to launch the command. If you want to start an external program without starting cmd.exe use proc_open() with the bypass_shell option set.

您也可以使用 popen() 代替 proc_open():

$handle = popen('C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --headless --disable-gpu --screenshot=D:\file211.png --window-size=1920,1200 http://google.com', 'r');

...