標準入力からの読み込み(php)
#!/usr/bin/php
<?php
if (posix_isatty(STDIN)) {
echo 'No stdin.'.PHP_EOL;
exit(1);
}
$fp = fopen('php://stdin', 'r');
while ($line = fgets($fp)) {
echo "STDIN> ".$line;
}
$ ls / | ./stdin.php STDIN> bin STDIN> boot STDIN> dev ... $ $ ./stdin.php No stdin.