php处理管道文件流

<?php
#!/usr/local/bin/php -q
function read(){
	$fp =  fopen("php://stdin", "r");
	while(!feof($fp)) {
		$tmp = fgets($fp, 255);
		$input = $input. $tmp;
	}
		
	fclose($fp);
	return $input;
}


$input = read();
echo $input;

php处理文件流

cat a.txt |/usr/local/bin/php in.php 

原文地址:https://www.cnblogs.com/lsmsky/p/4212077.html