php-doc-en/reference/dir/functions/opendir.xml
Derick Rethans 6efa7a6686 - WS
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@133767 c90b9560-bf6c-de11-be94-00142212c4b1
2003-06-30 15:02:18 +00:00

86 lines
2.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/dir.xml, last change in rev 1.2 -->
<refentry id="function.opendir">
<refnamediv>
<refname>opendir</refname>
<refpurpose>open directory handle</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>opendir</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
</methodsynopsis>
<para>
Returns a directory handle to be used in subsequent
<function>closedir</function>, <function>readdir</function>, and
<function>rewinddir</function> calls.
</para>
<para>
If <parameter>path</parameter> is not a valid directory or the
directory can not be opened due to permission restrictions or
filesystem errors, <function>opendir</function> returns &false; and
generates a PHP error of level <link linkend="errorfunc.constants">
E_WARNING</link>. You can suppress the error output of
<function>opendir</function> by prepending
'<link linkend="language.operators.errorcontrol">@</link>' to the
front of the function name.
</para>
<para>
<example>
<title><function>opendir</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$dir = "/tmp/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
print "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
?>
]]>
</programlisting>
</example>
</para>
<para>
As of <literal>PHP 4.3.0</literal> <parameter>path</parameter> can also
be any URL which supports directory listing, however only the <literal>file://</literal>
url wrapper supports this in <literal>PHP 4.3</literal>. As of
<literal>PHP 5.0.0</literal>, support for the <literal>ftp://</literal>
url wrapper is included as well.
</para>
<para>
See also <function>is_dir</function>,
<function>readdir</function>, and
<link linkend="class.dir">Dir</link>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->