mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Clarified that readdir will return all entries in a directory, not just the files. Updated examples to reflect that. Closes bug #60443.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@320392 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
0b0f44e0ae
commit
99a5cc447f
1 changed files with 13 additions and 13 deletions
|
@ -14,8 +14,8 @@
|
|||
<methodparam choice="opt"><type>resource</type><parameter>dir_handle</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the filename of the next file from the directory. The
|
||||
filenames are returned in the order in which they are stored by
|
||||
Returns the name of the next entry in the directory. The
|
||||
entries are returned in the order in which they are stored by
|
||||
the filesystem.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
@ -42,7 +42,7 @@
|
|||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns the filename on success&return.falseforfailure;.
|
||||
Returns the entry name on success&return.falseforfailure;.
|
||||
</para>
|
||||
&return.falseproblem;
|
||||
</refsect1>
|
||||
|
@ -51,7 +51,7 @@
|
|||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>List all files in a directory</title>
|
||||
<title>List all entries in a directory</title>
|
||||
<para>
|
||||
Please note the fashion in which <function>readdir</function>'s
|
||||
return value is checked in the examples below. We are explicitly
|
||||
|
@ -68,16 +68,16 @@
|
|||
|
||||
if ($handle = opendir('/path/to/files')) {
|
||||
echo "Directory handle: $handle\n";
|
||||
echo "Files:\n";
|
||||
echo "Entries:\n";
|
||||
|
||||
/* This is the correct way to loop over the directory. */
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
echo "$file\n";
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
echo "$entry\n";
|
||||
}
|
||||
|
||||
/* This is the WRONG way to loop over the directory. */
|
||||
while ($file = readdir($handle)) {
|
||||
echo "$file\n";
|
||||
while ($entry = readdir($handle)) {
|
||||
echo "$entry\n";
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
|
@ -90,16 +90,16 @@ if ($handle = opendir('/path/to/files')) {
|
|||
<para>
|
||||
<example>
|
||||
<title>
|
||||
List all files in the current directory and strip out <literal>.</literal>
|
||||
List all entries in the current directory and strip out <literal>.</literal>
|
||||
and <literal>..</literal>
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
if ($handle = opendir('.')) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if ($file != "." && $file != "..") {
|
||||
echo "$file\n";
|
||||
while (false !== ($entry = readdir($handle))) {
|
||||
if ($entry != "." && $entry != "..") {
|
||||
echo "$entry\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
|
|
Loading…
Reference in a new issue