php-doc-en/reference/dir/functions/dir.xml
Christoph Michael Becker 4754397753 Revert revision 351727 from phpdoc/en/trunk:
Document false and null return types

Cf. <https://news-web.php.net/php.doc.cvs/17645>.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351729 c90b9560-bf6c-de11-be94-00142212c4b1
2020-11-28 17:58:32 +00:00

127 lines
3.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- splitted from ./en/functions/dir.xml, last change in rev 1.2 -->
<refentry xml:id="function.dir" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>dir</refname>
<refpurpose>Return an instance of the Directory class</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>Directory</type><methodname>dir</methodname>
<methodparam><type>string</type><parameter>directory</parameter></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<para>
A pseudo-object oriented mechanism for reading a directory. The
given <parameter>directory</parameter> is opened.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>directory</parameter></term>
<listitem>
<para>
Directory to open
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
&note.context-support;
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an instance of <classname>Directory</classname>, or &null; with
wrong parameters, or &false; in case of another error.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>dir</function> example</title>
<para>
Please note the fashion in which <function>Directory::read</function>'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 <link linkend="language.operators.comparison">
Comparison Operators</link> for more information) &false; since
otherwise, any directory entry whose name evaluates to &false; will
stop the loop.
</para>
<programlisting role="php">
<![CDATA[
<?php
$d = dir("/etc/php5");
echo "Handle: " . $d->handle . "\n";
echo "Path: " . $d->path . "\n";
while (false !== ($entry = $d->read())) {
echo $entry."\n";
}
$d->close();
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
Handle: Resource id #2
Path: /etc/php5
.
..
apache
cgi
cli
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
The order in which directory entries are returned by the read method is
system-dependent.
</para>
</note>
</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:"~/.phpdoc/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
-->