freadBinary-safe file readDescriptionstringfreadresourcehandleintlengthfread reads up to
length bytes from the file pointer
referenced by handle. Reading stops when
length bytes have been read or EOF
(end of file) reached, whichever comes first.
]]>
On systems which differentiate between binary and text files
(i.e. Windows) the file must be opened with 'b' included in
fopen mode parameter.
]]>
When reading from network streams or pipes, such as those returned when
reading remote files or from
popen and proc_open, reading
will stop after a packet is available. This means that you should
collect the data together in chunks as shown in the example below.
]]>
The example above has better performance than the traditional approach
using while(!feof), as we are saving the overhead
of a function call per iteration.
If you just want to get the contents of a file into a string, use
file_get_contents as it has much better performance
than the code above.
See also fwrite, fopen,
fsockopen, popen,
fgets, fgetss,
fscanf, file, and
fpassthru.