Output all remaining data on a file pointer
Syntax
fpassthru ( resource $handle ) : int
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
If an error occurs, fpassthru() returns FALSE. Otherwise, fpassthru() returns the number of characters read from handle and passed through to the output.
Examples
1 · handle
<? $filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/file.txt'; $mode = 'r'; $handle = fopen($filename, $mode); fpassthru($handle); fclose($handle); ?>
Hello
2 · Return
<? $filename = $_SERVER['DOCUMENT_ROOT'] . '/assets/txt/file.txt'; $mode = 'r'; $handle = fopen($filename, $mode); $return = fpassthru($handle); fclose($handle); echo PHP_EOL . $return; ?>
Hello 5