Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

fpassthru()

Example

After writing the last of the data to the output buffer, read from the current place in the file until EOF:

<?php
$file = fopen(“test.txt”,“r”);
// Read first line
fgets($file);

// Read from the current position in file – until EOF, and then write the result to the output buffer
echo fpassthru($file);

fclose($file);
?>

Definition and Usage

The result is written to the output buffer by the fpassthru() function after it has read from the current place in the file until EOF.

Note: Make sure to open a binary file in binary mode on Windows before using fpassthru() on it.

Advice: If you have already written to the file, call rewind() to reset the file pointer to the beginning of the file.

Advice: Use the readfile() function in place of this to simply dump the contents of a file into the output buffer.

Syntax

fpassthru(file)

Parameter Values

 

Parameter

Description

file

Essential. indicates the open file that will be read.

Technical Details

Return Value:

The number of characters read from the file and passed through the output or FALSE on failure

PHP Version:

4.0+