Sophie

Sophie

distrib > Mandriva > 2008.1 > i586 > by-pkgid > 703d980c580707c382b4e43e25965bc5 > files > 8640

php-manual-pt_BR-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>opendir</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="Manual do PHP"
HREF="index.html"><LINK
REL="UP"
TITLE="Diretórios"
HREF="ref.dir.html"><LINK
REL="PREVIOUS"
TITLE="getcwd"
HREF="function.getcwd.html"><LINK
REL="NEXT"
TITLE="readdir"
HREF="function.readdir.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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"
>Manual do PHP</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.getcwd.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.readdir.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.opendir"
></A
>opendir</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN33589"
></A
><P
>    (PHP 3, PHP 4, PHP 5)</P
>opendir&nbsp;--&nbsp;Abre um manipulador de diretório</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN33592"
></A
><H2
>Descrição</H2
>resource <B
CLASS="methodname"
>opendir</B
> ( string path )<BR
></BR
><P
>&#13;     Retorna um handle de diretório para ser usado em chamadas
     subsequentes a <A
HREF="function.closedir.html"
><B
CLASS="function"
>closedir()</B
></A
>,
     <A
HREF="function.readdir.html"
><B
CLASS="function"
>readdir()</B
></A
>, e <A
HREF="function.rewinddir.html"
><B
CLASS="function"
>rewinddir()</B
></A
>.
    </P
><P
>&#13;     Se <CODE
CLASS="parameter"
>path</CODE
> não é um diretório válido ou se o
     diretório não pode ser aberto devi a restrições de permissões ou ainda
     por erro no sistema de arquivos, <B
CLASS="function"
>opendir()</B
> retorna <TT
CLASS="constant"
><B
>FALSE</B
></TT
> e
     gera um erro PHP de nível <A
HREF="ref.errorfunc.html#errorfunc.constants"
>&#13;     E_WARNING</A
>. Você pode suprimir a exibição da mensagem de erro de
     <B
CLASS="function"
>opendir()</B
> acrecentando um
     '<A
HREF="language.operators.errorcontrol.html"
>@</A
>' na
     frente do nome da função.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN33612"
></A
><P
><B
>Exemplo 1. exemplo de <B
CLASS="function"
>opendir()</B
></B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br />$dir </font><font color="#007700">= </font><font color="#DD0000">"/tmp/"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">// Abre um diretorio conhecido, e faz a leitura de seu conteudo<br /></font><font color="#007700">if (</font><font color="#0000BB">is_dir</font><font color="#007700">(</font><font color="#0000BB">$dir</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;if (</font><font color="#0000BB">$dh </font><font color="#007700">= </font><font color="#0000BB">opendir</font><font color="#007700">(</font><font color="#0000BB">$dir</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while ((</font><font color="#0000BB">$file </font><font color="#007700">= </font><font color="#0000BB">readdir</font><font color="#007700">(</font><font color="#0000BB">$dh</font><font color="#007700">)) !== </font><font color="#0000BB">false</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print </font><font color="#DD0000">"filename: $file : filetype: " </font><font color="#007700">. </font><font color="#0000BB">filetype</font><font color="#007700">(</font><font color="#0000BB">$dir </font><font color="#007700">. </font><font color="#0000BB">$file</font><font color="#007700">) . </font><font color="#DD0000">"\n"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#0000BB">closedir</font><font color="#007700">(</font><font color="#0000BB">$dh</font><font color="#007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     A partir do <TT
CLASS="literal"
>PHP 4.3.0</TT
> o parâmentro <CODE
CLASS="parameter"
>path</CODE
> pode ser
     qualquer tipo de URL que suporte a listagem de diretórios, mas somente o wrapper <TT
CLASS="literal"
>file://</TT
>
     era suportado no <TT
CLASS="literal"
>PHP 4.3</TT
>. A partir do
     <TT
CLASS="literal"
>PHP 5.0</TT
> o suporte ao wrapper <TT
CLASS="literal"
>ftp://</TT
>
     foi acrescentado.
    </P
><P
>&#13;     Veja também <A
HREF="function.is-dir.html"
><B
CLASS="function"
>is_dir()</B
></A
>,
     <A
HREF="function.readdir.html"
><B
CLASS="function"
>readdir()</B
></A
> e
     <A
HREF="class.dir.html"
>Dir</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.getcwd.html"
ACCESSKEY="P"
>Anterior</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Principal</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.readdir.html"
ACCESSKEY="N"
>Próxima</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>getcwd</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.dir.html"
ACCESSKEY="U"
>Acima</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>readdir</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>