In this lesson we will teach you
how to read data from a file using various PHP functions.
we can read a file we have to open it using fopen
Below is the code to read-open a
are the contents of "testFile.txt".
Now that the file is open, with read permissions enabled, we
can get started!
function is the staple for getting data out of a file.
requires a file handle and an integer to tell the
function how much data, in bytes, it is supposed to read.
character is equal to one byte. If you wanted to read the first five
characters then you would use five as the integer.
first five characters from the testFile.txt file
are now stored inside $theData. You could echo this
string, $theData, or write it to another file.
If you wanted to read all the data from the file, then you
need to get the size of the file.
function returns the length of a file, in bytes, which is just what we
function requires the name of
the file that is to be sized up.
NoteFor more detail please see Php Manual at http://www.php.net