• PHP Video Tutorials

PHP - Function fpassthru()



The fpassthru() function can read all data from the current position in an open file until EOF and can write the result to an output buffer. This function can return the number of characters passed, or false on failure.

Syntax

int fpassthru ( resource $handle )

When we can use the fpassthru() function in a binary file on Windows System, the file must be opened in binary mode.

Example

<?php
   $file = fopen("/PhpProject/sample.txt", "r");
 
   // Read first line
   fgets($file);

   // Send rest of the file to the output buffer
   echo fpassthru($file);
   fclose($file);
?>

Output

Tutorix7
php_function_reference.htm
Advertisements