After writing the last of the data to the output buffer, read from the current place in the file until EOF:
<?php $file = fopen(“test.txt”,“r”); // Read first line fgets($file); // Read from the current position in file – until EOF, and then write the result to the output buffer echo fpassthru($file); fclose($file); ?> |
The result is written to the output buffer by the fpassthru() function after it has read from the current place in the file until EOF.
Note: Make sure to open a binary file in binary mode on Windows before using fpassthru() on it.
Advice: If you have already written to the file, call rewind() to reset the file pointer to the beginning of the file.
Advice: Use the readfile() function in place of this to simply dump the contents of a file into the output buffer.
fpassthru(file) |
Parameter |
Description |
file |
Essential. indicates the open file that will be read. |
Return Value: |
The number of characters read from the file and passed through the output or FALSE on failure |
PHP Version: |
4.0+ |