PHP proc_open 不起作用 - 给我“数组中缺少句柄限定符" [英] PHP proc_open won't work - gives me "Missing handle qualifier in array"
本文介绍了PHP proc_open 不起作用 - 给我“数组中缺少句柄限定符"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
警告:proc_open():C:\...\updatedots.php 第 102 行的数组中缺少句柄限定符
Warning: proc_open(): Missing handle qualifier in array in C:\...\updatedots.php on line 102
我试图打开记事本,然后在 2 秒后关闭它.这是我的代码:
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")
但 0 =>数组(管道",r")
^^
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"]);
这篇关于PHP proc_open 不起作用 - 给我“数组中缺少句柄限定符"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文