开发者

PHP proc_open won't work - gives me "Missing handle qualifier in array"

Warning: proc_open(): Missing ha开发者_如何学编程ndle qualifier in array in C:\...\updatedots.php on line 102

I'm trying to open notepad the close it after 2 seconds. This is my code:

$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"]);

Any idea what this error means and what causes it?


It is not 0 => array("pipe" => "r") but 0 => array("pipe", "r") ^^

Additionally, when giving a filename you need to specify the mode to use. This works on my machine:

$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"]); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜