<HTML ><HEAD ><TITLE >fpassthru</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Filesystem functions" HREF="ref.filesystem.html"><LINK REL="PREVIOUS" TITLE="fopen" HREF="function.fopen.html"><LINK REL="NEXT" TITLE="fputs" HREF="function.fputs.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.fopen.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.fputs.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.fpassthru" ></A >fpassthru</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN25968" ></A ><P > (PHP 3, PHP 4 )</P >fpassthru -- Output all remaining data on a file pointer</DIV ><DIV CLASS="refsect1" ><A NAME="AEN25971" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >fpassthru</B > ( resource handle)<BR ></BR ><P > Reads to EOF on the given file pointer from the current position and writes the results to the output buffer. </P ><P > If an error occurs, <B CLASS="function" >fpassthru()</B > returns <TT CLASS="constant" ><B >FALSE</B ></TT >. Otherwise, <B CLASS="function" >fpassthru()</B > returns the number of characters read from <TT CLASS="parameter" ><I >handle</I ></TT > and passed through to the output. </P ><P > The file pointer must be valid, and must point to a file successfully opened by <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A >, <A HREF="function.popen.html" ><B CLASS="function" >popen()</B ></A >, or <A HREF="function.fsockopen.html" ><B CLASS="function" >fsockopen()</B ></A >. You may need to call <A HREF="function.rewind.html" ><B CLASS="function" >rewind()</B ></A > to reset the file pointer to the beginning of the file if you have already written data to the file. The file is closed when <B CLASS="function" >fpassthru()</B > is done reading it (leaving <TT CLASS="parameter" ><I >handle</I ></TT > useless). </P ><P > If you just want to dump the contents of a file to the output buffer, without first modifying it or seeking to a particular offset, you may want to use the <A HREF="function.readfile.html" ><B CLASS="function" >readfile()</B ></A >, which saves you the <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A > call. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note: </B > When using <B CLASS="function" >fpassthru()</B > on a binary file on Windows systems, you should make sure to open the file in binary mode by appending a <TT CLASS="literal" >b</TT > to the mode used in the call to <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A >. </P ><P > You are encouraged to use the <TT CLASS="literal" >b</TT > flag when dealing with binary files, even if your system does not require it, so that your scripts will be more portable. </P ></BLOCKQUOTE ></DIV ><P > See also <A HREF="function.readfile.html" ><B CLASS="function" >readfile()</B ></A >, <A HREF="function.fopen.html" ><B CLASS="function" >fopen()</B ></A >, <A HREF="function.popen.html" ><B CLASS="function" >popen()</B ></A >, and <A HREF="function.fsockopen.html" ><B CLASS="function" >fsockopen()</B ></A > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.fopen.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.fputs.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >fopen</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.filesystem.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >fputs</TD ></TR ></TABLE ></DIV ></BODY ></HTML >