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 

posted on 2015-01-08 22:52  E猫  阅读(860)  评论(0编辑  收藏  举报

导航