Easy Tutorial
❮ Func Date Localtime Func Math Rad2Deg ❯

PHP fpassthru() Function



Definition and Usage

The fpassthru() function reads all data from the current position in an open file until the end of the file (EOF) and writes the result to the output buffer.

This function returns the number of characters passed, or FALSE on failure.

Syntax

Parameter Description
file Required. Specifies the open file or resource to read from.

Tips and Notes

Note: When using the fpassthru() function on binary files in a Windows system, remember that you must open the file in binary mode.

Tip: If you have written data to the file, you must call rewind() to set the file pointer to the beginning of the file.

Tip: If you only want to output the contents of a file to the output buffer without modifying it, use the readfile() function instead, which saves you from calling fopen().


Example 1

The above code will output:

59 indicating the number of characters passed.


Example 2

Dump the index page of a web server:


❮ Func Date Localtime Func Math Rad2Deg ❯