Tutorial for fread() in Reading file

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:-

Tagged : / / / / / /
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x