目录

PHP fpassthru() 函数

❮ PHP 文件系统参考

示例

从文件中的当前位置开始读取 - 直到 EOF,然后将剩余数据写入输出缓冲区:

<?php
$file = fopen("test.txt","r");
// Read first line
fgets($file);

// Read from the current position in file - until EOF, and then write the result to the output buffer
echo fpassthru($file);

fclose($file);
?>
运行示例 »

定义和用法

fpassthru() 函数从文件中的当前位置读取 - 直到 EOF,然后将结果写入输出缓冲区。

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

提示:称呼倒带()如果您已经写入文件,则将文件指针设置为文件的开头。

提示:要将文件的内容转储到输出缓冲区,请使用读取文件()函数代替。

语法

fpassthru( file)

参数值

Parameter Description
file Required. Specifies the open file to read from


技术细节

返回值: 从文件读取并通过输出的字符数,失败时为 FALSE
PHP 版本: 4.0+

❮ PHP 文件系统参考