Fread: Calculates the length in bytes, reads the data according to the specified length and number of times, and stops after the end is encountered or the specified length is completed.
Fgets: Full line read, encountered carriage return newline or end stop. Used in text mode.
The function of the fgets function of the read string function is to read a string from the specified file into a character array,
The function call is in the form of:
Fgets (character array name, n, file pointer);
where n is a positive integer.
Indicates that a string that is read from a file does not exceed n-1 characters.
After the last character read, add the string end flag ' \ s '.
For example: Fgets (STR,N,FP), the meaning is to read from the file referred to in the FP n-1 characters into the character array str.
Read by line) fgets () reads one line at a time and points to the next line.
So read the front 10 lines and clear them.
Then the next time fgets () is the 11th line.
Fgets () How do you read one line at a time? How do you set it?
Fread is a read-write function for the entire block of data that can be used to read and write a set of data, such as an array element, a structure variable value, and so on.
The general form of a read block function call is:
Fread (BUFFER,SIZE,COUNT,FP), where buffer is a pointer,
In the Fread function, it represents the first address that holds the input data.
A size represents the number of bytes of data block.
Count represents the number of block blocks of data to read and write.
The FP represents a file pointer.
For example: Fread (FA,4,5,FP); The meaning is from the file referred to in the FP, each read 4
Fread--read files (can be used safely in binary files)
When you open a file on a system that distinguishes between binary files and text files, such as Windows,
The mode parameter of the fopen () function should be added ' B '.
$handle = fopen ($filename, "RB");
I use the method, if you have a good way, everybody share next AH
Copy the Code code as follows:
$handle = @fopen ($path, "R");
if ($handle) {
$buffer = Fread ($handle, 400);
Echo $buffer;
Fclose ($handle);
}
?>
The above describes the efficiency source hard drive bad channel detection efficiency of PHP read text files under the original code, including the efficiency of the source hard drive bad detection aspects of the content, I hope that the PHP tutorial interested friends have helped.