fpassthru
输出文件指针处的所有剩余数据
fpassthru()
函数输出文件指针处的所有剩余数据。
该函数将给定的文件指针从当前的位置读取到 EOF,并把结果写到输出缓冲区。
<?php $file = fopen("test.txt","r"); // 读取第一行 fgets($file); // 把文件的其余部分发送到输出缓存 echo fpassthru($file); fclose($file); ?>
输出:
There are three lines in this file. This is the last line.59
注:59 指示被传递的字符数。
转储 www 服务器的 index 页:
<?php $file = fopen("http://www.example.com","r"); fpassthru($file); ?>
fpassthru(file)
参数 | 描述 |
---|---|
file | 必需。规定要读取的打开文件或资源。 |
如果发生错误,fpassthru()
返回 false。否则 fpassthru() 返回从 file 读取并传递到输出的字符数目。
文件指针必须有效,并且必须指向一个由 fopen()
或 fsockopen()
成功打开(但还没有被 fclose()
关闭)的文件。