6

警告:proc_open():第 102 行 C:\...\updatedots.php 中的数组中缺少句柄限定符

我正在尝试打开记事本并在 2 秒后关闭它。这是我的代码:

$descriptorspec = array(
    0 => array("pipe" => "r"),
    1 => array("pipe" => "w"),
    2 => array("file" => "logs/errors.txt")
);

// Create child and start process
$child = array("process" => null, "pipes" => array());
$child["process"] = proc_open("notepad.exe > nul 2>&1", $descriptorspec, $child["pipes"]);

知道这个错误是什么意思,是什么原因造成的?

4

1 回答 1

10

不是0 => array("pipe" => "r")但是0 => array("pipe", "r")^^

此外,在提供文件名时,您需要指定要使用的模式。这适用于我的机器:

$descriptorspec = array(
    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("file", "logs/errors.txt", "a") ); 
// Create child and start process 
$child = array("process" => null, "pipes" => null); 
$child["process"] = proc_open("notepad.exe > nul 2>&1", $descriptorspec, $child["pipes"]); 
于 2011-05-18T17:11:44.847 回答