
fread
(PHP 4, PHP 5)
fread — 读取文件(可安全用于二进制文件)
说明
string fread
( resource $handle
, int $length
)
fread() 从文件指针
handle 读取最多
length 个字节。
该函数在遇上以下几种情况时停止读取文件:
读取了 length 个字节
到达了文件末尾(EOF)
a packet becomes available or the
socket timeout occurs (for network streams)
if the stream is read buffered and it does not represent a plain file, at
most one read of up to a number of bytes equal to the chunk size (usually
8192) is made; depending on the previously buffered data, the size of the
returned data may be larger than the chunk size.
参数
handle
文件系统指针,是典型地由
fopen() 创建的 resource(资源)。
length
最多读取 length 个字节。
返回值
返回所读取的字符串, 或者在失败时返回 FALSE。
范例
Example #1 一个简单的 fread() 例子
//