Website Scripts And Cloud Tutorials

Read file using php


Apr 1, 2014

Last updated on November 18th, 2015 at 03:47 am

Click to rate this tutorial!
[Total: 8 Average: 4.4]

Simple php code for reading lines
Using the below script you can easily read a txt file. Let the text file be and you are using fopen() to open the file and ‘r’ argument to Read the file which is opened.

$file = fopen("", "r") or exit("Unable to open file!");
//Output of the text file
//<br> is used to break b/w lines
 echo fgets($file). "<br />";

fclose() as the name says will close the file once the read operation is done. It is always a best practice to close the file once data is read.

Click to rate this tutorial!
[Total: 8 Average: 4.4]
5 thoughts on “Read file using php”

Leave a Reply

Your email address will not be published.