The fpassthru() function in PHP is an inbuilt function which is used to read data from a current position from a specified file until end of file and then write the result to the output buffer. The file which has to be read is sent as a parameter to the fpassthru() function and it returns the number of characters passed on success or FALSE on failure.
int fpassthru ( $file )
The fpassthru() function in PHP accepts one parameter.
- file: It is a mandatory parameter which specifies the file.
- It returns the number of characters passed on success or FALSE on failure.
- The file should be opened in binary mode while using the fpassthru() function on a binary file on Windows.
- rewind() function should be called to set the file pointer to the beginning of the file if you have already written to the file.
- the readfile() function should be used if you want to dump the contents of a file to the output buffer without modifying it.
Below is the implementation of fpassthru() function.
Suppose a file gfg.txt contains the following content :
Portal for Geeks!
Portal for Geeks!17
Note: 17 indicates the number of characters passed.
- How to get the function name inside a function in PHP ?
- PHP | max( ) Function
- PHP | min( ) Function
- PHP Ds\Set get() Function
- PHP | end() Function
- PHP | dir() Function
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- PHP | Ds\Map first() Function
- PHP Ds\Map sum() Function
- PHP Ds\Set sum() Function
- PHP | key() Function
- PHP | pos() Function
- PHP | sin( ) Function
- PHP | tan( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.