PHP proc_open 不起作用 - 给我“数组中缺少句柄限定符”

发布于 2024-11-08 20:26:19 字数 534 浏览 7 评论 0 原文

警告: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"]);

知道这个错误意味着什么以及导致它的原因吗?

Warning: proc_open(): Missing handle 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何其悲哀 2024-11-15 20:26:19

它不是 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"]); 

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"]); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文