Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 14

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>dir</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="Directory functions"
HREF="ref.dir.html"><LINK
REL="PREVIOUS"
TITLE="chroot"
HREF="function.chroot.html"><LINK
REL="NEXT"
TITLE="closedir"
HREF="function.closedir.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.chroot.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.closedir.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="class.dir"
></A
>dir</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN19949"
></A
>dir&nbsp;--&nbsp;directory class</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN19952"
></A
><H2
>Description</H2
><pre
class="classsynopsis"
> <SPAN
class="ooclass"
>class <span
class="classname"
>dir </span
></SPAN
>{
<code
class="constructorsynopsis"
>&#13;  dir(<span
class="methodparam"
><span
class="type"
>string </span
><span
class="parameter"
>directory</span
></span
>);&#13;</code
><code
class="fieldsynopsis"
>  <span
class="type"
>string </span
><span
class="varname"
>path</span
>;&#13;</code
><code
class="fieldsynopsis"
>  <span
class="type"
>resource </span
><span
class="varname"
>handle</span
>;&#13;</code
><code
class="methodsynopsis"
>&#13;  <span
class="type"
>string </span
>read();&#13;</code
><code
class="methodsynopsis"
>  <span
class="type"
>void </span
>rewind();&#13;</code
><code
class="methodsynopsis"
>  <span
class="type"
>void </span
>close();&#13;</code
>}</pre
><P
>&#13;     A pseudo-object oriented mechanism for reading a directory.  The
     given <TT
CLASS="parameter"
><I
>directory</I
></TT
> is opened.  Two properties
     are available once the directory has been opened.  The handle
     property can be used with other directory functions such as
     <A
HREF="function.readdir.html"
><B
CLASS="function"
>readdir()</B
></A
>, <A
HREF="function.rewinddir.html"
><B
CLASS="function"
>rewinddir()</B
></A
> and
     <A
HREF="function.closedir.html"
><B
CLASS="function"
>closedir()</B
></A
>.  The path property is set to path
     the directory that was opened.  Three methods are available:
     read, rewind and close.
    </P
><P
>&#13;     Please note the fashion in which <B
CLASS="function"
>dir()</B
>'s
     return value is checked in the example below. We are explicitly
     testing whether the return value is identical to (equal to and of
     the same type as--see <A
HREF="language.operators.comparison.html"
>&#13;     Comparison Operators</A
> for more information) <TT
CLASS="constant"
><B
>FALSE</B
></TT
> since
     otherwise, any directory entry whose name evaluates to <TT
CLASS="constant"
><B
>FALSE</B
></TT
> will
     stop the loop.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN19990"
></A
><P
><B
>Example 1. <B
CLASS="function"
>dir()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>$d = dir("/etc");
echo "Handle: ".$d-&#62;handle."&#60;br&#62;\n";
echo "Path: ".$d-&#62;path."&#60;br&#62;\n";
while (false !== ($entry = $d-&#62;read())) {
    echo $entry."&#60;br&#62;\n";
}
$d-&#62;close();</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      The order in which directory entries are returned by the read method is
      system-dependent.
     </P
></BLOCKQUOTE
></DIV
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Note: </B
>
      This defines the internal class
      <B
CLASS="classname"
>Directory</B
>, meaning that you will not be
      able to define your own classes with that name. For a full list
      of predefined classes in PHP, please see <A
HREF="reserved.classes.html"
>Predefined Classes</A
>.
     </P
></BLOCKQUOTE
></DIV
></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.chroot.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.closedir.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>chroot</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.dir.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>closedir</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>