What is fread()?
The file’s data is read using the PHP
fread() function. Two parameters are required: file resource and file size.
Read the File using
fread() method, we may read content from an already open file. There are two parameters to the
- first is the filename
- and the second argument specifies the size in bytes for the content to be read.
Let’s take an example, if we have a file studytonight.txt with following content:
Studytonight is for coding enthusiasts!
If we wish to read the file’s complete content, we’ll open it in read mode and then use the