Read 10 bytes from an open file:
<?php
$file = fopen("test.txt","r");
fread($file,"10");
fclose($file);
?>
Run Example »
The fread() reads from an open file.
The function will stop at the end of the file or when it reaches the specified length, whichever comes first.
fread(
file,
length)
Parameter | Description |
---|---|
file | Required. Specifies the open file to read from |
length | Required. Specifies the maximum number of bytes to read |
Return Value: | The read string, FALSE on failure |
---|---|
PHP Version: | 4.0+ |
Binary Safe: | Yes |
Read entire file:
<?php
$file = fopen("test.txt","r");
fread($file,filesize("test.txt"));
fclose($file);
?>
Run Example »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!