The fpassthru() function reads all data from the current position in an open file, until EOF, and writes the result to the output buffer.
PHP fpassthru() Function has the following syntax.
fpassthru(file)
Parameter | Is Required | Description |
---|---|---|
file | Required. | Open file or resource to read from |
This function returns the number of characters passed or FALSE on failure.
When using fpassthru() on a binary file on Windows, remember to open the file in binary mode.
<?php
$file = fopen("test.txt","r");
fgets($file);// Read first line
echo fpassthru($file);// Send rest of the file to the output buffer
fclose($file);
?>
The code above generates the following result.
Dump index page of a www server:
<?php
$file = fopen("http://www.google.com","r");
echo fpassthru($file);
?>
The code above generates the following result.