基本上,我想从标准输入读取行,但我不想在等待新数据时被阻塞。就像使用带有超时的流一样。
$stdin = fopen('php://stdin', 'r');
do {
$line = fgets($stdin);
// No input right now
if (empty($line)) {
// Do something before waiting for more input
}
} while (1);