输入流
fopen 不仅能读文件,还可读取指定内置协议的各种流,返回资源指针。
fgets 读取一行资源,失败则返回。
$handle = fopen('php://stdin','r');
$input = fgets($handle);
if($input){
echo $input;
}
fclose($handle);
或者
$str = fgets(STDIN);
输入流
fopen 不仅能读文件,还可读取指定内置协议的各种流,返回资源指针。
fgets 读取一行资源,失败则返回。
$handle = fopen('php://stdin','r');
$input = fgets($handle);
if($input){
echo $input;
}
fclose($handle);
或者
$str = fgets(STDIN);