Basically, I'm looking to read strings from STDIN, but I don't want to block while waiting for new data. Almost like using a thread with a timeout.
$stdin = fopen('php://stdin', 'r');
do {
$line = fgets($stdin);
if (empty($line)) {
}
} while (1);
source
share