fpassthru
All remaining data at the output file pointer
fpassthru()
function outputs all remaining data at the file pointer.
This function reads the given file pointer to EOF from the current location and writes the result to the output buffer.
<?php $file = fopen ( "test.txt" , "r" ) ; // Read the first line fgets ( $file ) ; // Send the rest of the file to the output cache echo fpassthru ( $file ) ; fclose ( $file ) ; ?>
Output:
There are three lines in this file. This is the last line.59
Note: 59 Indicates the number of characters passed.
Dump the index page of the www server:
<?php $file = fopen ( "http://www.example.com" , "r" ) ; fpassthru ( $file ) ; ?>
fpassthru ( file )
parameter | describe |
---|---|
file | Required. Specifies the open file or resource to be read. |
If an error occurs, fpassthru()
returns false. Otherwise fpassthru() returns the number of characters read from the file and passed to the output.
The file pointer must be valid and must point to a file that was successfully opened by fopen()
or fsockopen()
(but has not been closed fclose()
).