php fpassthru()函数

时间:2017-03-15
php fpassthru()函数从打开的文件中的当前位置读取所有数据,直到EOF,并将结果写入输出缓冲区。本文章向大家介绍php fpassthru()函数的基本使用方法和实例,需要的朋友可以参考一下。

定义

fpassthru()函数从打开的文件中的当前位置读取所有数据,直到EOF,并将结果写入输出缓冲区。

语法

PHP fpassthru()函数具有以下语法。

fpassthru(file)

参数

参数 是否必须 描述
file 需要。 打开的要读取的文件或资源

返回值

成功时此函数返回字符数或失败时返回FALSE。

注意

当在Windows上的二进制文件上使用fpassthru()时,请记住以二进制模式打开该文件。

实例

<?php
/*
http://www.manongjc.com/article/1796.html
作者:码农教程
*/
$file = fopen("test.txt","r");
fgets($file);// Read first line
echo fpassthru($file);// Send rest of the file to the output buffer
fclose($file);
?>

实例2

转储www服务器的index页面:

<?php
$file = fopen("http://www.google.com","r");
echo fpassthru($file);
?>