Fread: Computes the length in byte bits, reads the data at the specified length and number, stops after it encounters the end or completes the specified length read.
Fgets: Full row reads, encounters carriage return or end stop. Used in text mode.
The function of the Fgets function is to read a string into a character array from the specified file.
The form of a function call is:
Fgets (character array name, n, file pointer);
where n is a positive integer.
Indicates that a string read from a file does not exceed n-1 characters.
After the last character read, add a string end sign '.
For example: Fgets (STR,N,FP) is meant to read n-1 characters into the character array str from the file referred to in FP.
Read by line Fgets () points to the next line each time a row is read.
So read the front 10 lines and clear them.
Then the next fgets () is the 11th line.
Fgets () How to read a line every 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, the value of a struct variable, 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.
The size represents the number of bytes in the data block.
Count represents the number of blocks of data blocks to read and write.
FP represents a file pointer.
For example: Fread (FA,4,5,FP); The meaning of this is that from the file in the FP reference, read 4 each time
Fread-Read files (safe for binary files)
When you open a file on a system that distinguishes binaries and text files, such as Windows,
The mode parameter of the fopen () function is added ' B '.
$handle = fopen ($filename, "RB");
I use the method, if you have a good method, everybody share under AH
Copy Code code as follows:
<?php
$handle = @fopen ($path, "R");
if ($handle) {
$buffer = Fread ($handle, 400);
echo $buffer;
fclose ($handle);
}
?>