php fread() function is used to read files (safe for binary files).
php fread() function Syntax
Function: Read files (safe for binary files).
Syntax:
fread(file,length)
Parameters:
file Required. Specifies that the file should be opened for reading.
length Required. Specifies the maximum number of bytes to read.
Explanation: The file pointer file can read up to length bytes. This function is called after reading up to length bytes, or when EOF is reached, or (for network streams) when a packet is available, or (after opening a user space stream) 8192 bytes have been read. Reading of the file will stop.
php fread() function example
<?php $file = fopen("./test.txt","r"); echo fread($file,filesize("./test.txt")); ?>
This article is an introduction to the PHP fread function. I hope it will be helpful to friends in need!
The above is the detailed content of How to use fread function. For more information, please follow other related articles on the PHP Chinese website!