fread Binary-safe file read &reftitle.description; stringfread resourcehandle intlength fread reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read EOF (end of file) is reached a packet becomes available or the socket timeout occurs (for network streams) 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. &reftitle.parameters; handle &fs.file.pointer; length Up to length number of bytes read. &reftitle.returnvalues; Returns the read string &return.falseforfailure;. &reftitle.examples; A simple <function>fread</function> example ]]> Binary <function>fread</function> example On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen mode parameter. ]]> Remote <function>fread</function> examples When reading from anything that is not a regular local file, such as streams returned when reading remote files or from popen and fsockopen, reading will stop after a packet is available. This means that you should collect the data together in chunks as shown in the examples below. ]]> ]]> &reftitle.notes; 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. Note that fread reads from the current position of the file pointer. Use ftell to find the current position of the pointer and rewind to rewind the pointer position. &reftitle.seealso; fwrite fopen fsockopen popen fgets fgetss fscanf file fpassthru ftell rewind unpack