Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > ebb1914cf182a88528b4547490db1dd8 > files > 649

kdewebdev-quanta-doc-3.5.9-2mdv2008.1.x86_64.rpm

<HTML
><HEAD
><TITLE
>fgets</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Filesystem functions"
HREF="ref.filesystem.html"><LINK
REL="PREVIOUS"
TITLE="fgetcsv"
HREF="function.fgetcsv.html"><LINK
REL="NEXT"
TITLE="fgetss"
HREF="function.fgetss.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><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.fgetcsv.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.fgetss.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.fgets"
>fgets</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN8507"
></A
>fgets -- Get line from file pointer</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN8510"
></A
><H2
>Description</H2
><DIV
CLASS="funcsynopsis"
><P
></P
><CODE
CLASS="FUNCDEF"
>string fgets</CODE
>(int fp, int length);<P
></P
></DIV
><P
>&#13;     Returns a string of up to length - 1 bytes read from the file
     pointed to by fp. Reading ends when length - 1 bytes have been
     read, on a newline (which is included in the return value), or on
     EOF (whichever comes first).
    </P
><P
>&#13;     If an error occurs, returns false.
    </P
><P
>&#13;     Common Pitfalls:
    </P
><P
>&#13;     People used to the 'C' semantics of fgets should note the
     difference in how EOF is returned.
    </P
><P
>&#13;     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
>.
    </P
><P
>&#13;     A simple example follows:
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 1. Reading a file line by line</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;$fd = fopen ("/tmp/inputfile.txt", "r");
  3&nbsp;while (!feof($fd)) {
  4&nbsp;    $buffer = fgets($fd, 4096);
  5&nbsp;    echo $buffer;
  6&nbsp;}
  7&nbsp;fclose ($fd);
  8&nbsp;      </PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
> 
     See also <A
HREF="function.fread.html"
><B
CLASS="function"
>fread()</B
></A
>, <A
HREF="function.fopen.html"
><B
CLASS="function"
>fopen()</B
></A
>,
     <A
HREF="function.popen.html"
><B
CLASS="function"
>popen()</B
></A
>, <A
HREF="function.fgetc.html"
><B
CLASS="function"
>fgetc()</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
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.fgetcsv.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.fgetss.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>fgetcsv</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.filesystem.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>fgetss</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>