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()
Using the fread()
method, we may read content from an already open file. There are two parameters to the fread()
function:
- first is the filename
- and the second argument specifies the size in bytes for the content to be read.
Example:-
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 fread()
method.
Output:-

Latest posts by Ashwani Kumar (see all)
- What is Cookies and Why it is Used? - May 24, 2023
- TOP trends of transitions in TikTok - May 10, 2023
- Top DevOps Trainers in Netherlands and Amsterdam - October 9, 2022