Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中从stdin检测EOT_Php_Stdin - Fatal编程技术网

在PHP中从stdin检测EOT

在PHP中从stdin检测EOT,php,stdin,Php,Stdin,这似乎是一项非常简单的任务,但我很难识别通过stdin输入到PHP[5.5.x]的输入的结尾。fgets(STDIN)似乎决定停止等待没有可识别信号的输入,而不是传递0x04EOT字符来限制最终字符串。最明显的演示是通过代码: <?php while(substr(rtrim(fgets(STDIN), PHP_EOL), -1) != 0x04) { echo "Input received."; } 部分答案:两者都有 通过管道传递\x04,并与0x04文本进行比较,以及 传

这似乎是一项非常简单的任务,但我很难识别通过stdin输入到PHP[5.5.x]的输入的结尾。fgets(STDIN)似乎决定停止等待没有可识别信号的输入,而不是传递
0x04
EOT字符来限制最终字符串。最明显的演示是通过代码:

<?php
while(substr(rtrim(fgets(STDIN), PHP_EOL), -1) != 0x04) {
    echo "Input received.";
}
部分答案:两者都有

  • 通过管道传递
    \x04
    ,并与
    0x04
    文本进行比较,以及
  • 传递
    \u0004
    [使用NodeJS的
    子进程
    ],并与
    mb\u convert\u编码(';','UTF-8','HTML-ENTITIES')创建的EOT字符进行比较。
  • 成功并允许程序终止。将后一个比较应用于
    \x04
    具有与Ctrl+D相同的效果,Ctrl+D过去和现在都具有相同的效果