Current Location: Home> Function Categories> fpassthru

fpassthru

All remaining data at the output file pointer
Name:fpassthru
Category:File system
Programming Language:php
One-line Description:Read data from the open file until EOF, and write the result to the output buffer.

Definition and usage

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.

Example

Example 1

 <?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.

Example 2

Dump the index page of the www server:

 <?php
$file = fopen ( "http://www.example.com" , "r" ) ;
fpassthru ( $file ) ;
?>

grammar

 fpassthru ( file )
parameter describe
file Required. Specifies the open file or resource to be read.

illustrate

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() ).

Similar Functions
  • alias for fwrite fputs

    fputs

    aliasforfwrite
  • Close an open file pointer fclose

    fclose

    Closeanopenfilepoint
  • Provide information about the document stat

    stat

    Provideinformationab
  • Change the current umask umask

    umask

    Changethecurrentumas
  • See unlink() or unset() (PHP does not have delete keywords or functions) delete

    delete

    Seeunlink()orunset()
  • Open a file or URL fopen

    fopen

    OpenafileorURL
  • Read a line from a file pointer and filter out HTML tags fgetss

    fgetss

    Readalinefromafilepo
  • Create a file with a unique file name tempnam

    tempnam

    Createafilewithauniq
Popular Articles