fpassthru - prints all remaining data file pointers
fpassthru
(PHP 4, PHP 5)
fpassthru - Output all remaining data file pointers
Description
international fpassthru (resource $ handle)
Reads the EOF analysis's specific file pointer from the current location and writes the results to the output buffer.
You may need to rewind() the file pointer to the beginning of the file if you have written data to the file.
If you just want to dump the file contents to the output buffer without first modifying or seeking a specific offset, you may want to use readfile(), thus saving you a call to the fopen() function.
Parameters
Handle
The file pointer must be valid and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).
Return value
If an error occurs, fpassthru() returns FALSE. Otherwise, fpassthru() returns the number of characters read processed and passed through the output.
Example
Example #1 Using fpassthru() with binaries
// open the file in a binary mode
$name = './img/ok.png';
$fp = fopen($name, 'rb');
// send the right headers
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));
// dump the picture and stop the script
fpassthru($fp);
exit;
?>