PHP read the file , Fread is used to read the contents of the file opened with fopen, let's take a look at the fread and gets instance tutorial.
I apologize simply by taking the point of actually getting to your profile file. In this lesson we will teach you how to read data from files using a variety of PHP functions.
PHP-Open File: Read
In the information file we can read, we must use the feature to open and open the file for reading. Here the code is changed to open file, we build the lessons in PHP file collection.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' R ');
The document we built in the past is known as "TestFile.txt". Your PHP script, you should write live in the same directory "Text.txt". The following is the contents of the file from the file collection.
PHP-File reading: Fread features
The Fread function is a staple to get data from a file. This feature requires a file handle that we have and an integer that tells the function how much data, in bytes, it is read.
A word, equal to one byte. If you want to read the first five-year character then you can use integers for five years.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' R ');
$theData = Fread ($fh, 5);
Fclose ($FH);
Echo $theData;
The first five-year character TestFile.txt from now archives stored in $ thedata. You can repeat this string, $ thedata, or write to another file.
If you want to read all the data files, then you need to get the size of the file. The file size function returns the length of the file, in bytes, which is what we need! The file's functional requirements for the file name will be sized up.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' R ');
$theData = Fread ($fh, FileSize ($myFile));
Fclos E ($FH);
Echo $theData;
php-file reading: Gets function
PHP can also read the data line time from a file to get the feature. This can or may not be useful to you, programmer. If you have your data separated with the new line then you can read a portion of the data at the time and get the function.
Fortunately our "testFile.txt" file is separate from the new production line, we can take advantage of this feature.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' R '),
$theData = fgets ($fh),
fclose ($FH);
Echo $ Thedata;
www.111cn.net/phper/php.html