I understand the differences between fgets() and fgetss() but I don\'t get the difference between fgets() and fread()<
The accepted answer is correct, but there is one more case for fread
to stop reading. fread
has a chunk limit of 8192 bytes. I discovered this when I was getting different results from fread($stream, 8300)
and fget($stream, 8300)
.
From fread docs:
if the stream is read buffered and it does not represent a plain file, at most one read of up to a number of bytes equal to the chunk size (usually 8192) is made; depending on the previously buffered data, the size of the returned data may be larger than the chunk size.