Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

readdir

Description

Read entry from directory handle

Syntax

readdir(?resource $dir_handle = null): string|false

Parameters

dir_handle

The directory handle resource previously opened with opendir(). If the directory handle is not specified, the last link opened by opendir() is assumed.

Return

Returns the entry name on success or false on failure. WarningThis function may return Boolean false, but may also return a non-Boolean value which evaluates to false. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

Examples

1 · void

<?

$directory = ".";

if(opendir($directory))
{
    while(($return = readdir()) !== false)
    {
        echo "$return\n";
    }
    closedir();
}

?>
stream_filter_prepend.txt
index.php
simpletext.xbm
my.sock
stream_filter_remove.txt
vfprintf.txt
red_crop_trans.png
simpletext.jpg
dashedline.png
error_log
php.webp
..
simple.gd
depth1
stringup.png
imagecolortransparent.png
red_300.png
stat.txt
meta.html
paletteimage.png
imagefilledrectangle.png
simple.gd2
.
stream_filter_register.txt
simpletext.wbmp
phplogo.jpg
127.0.0.1
file.png
imageline.png
php.bmp
stream_copy_to_stream.txt
stream_filter_append.txt

2 · dir_handle

<?

$directory = ".";

if($dir_handle = opendir($directory))
{
    while(($return = readdir($dir_handle)) !== false)
    {
        echo "$return\n";
    }
    closedir($dir_handle);
}

?>
stream_filter_prepend.txt
index.php
simpletext.xbm
my.sock
stream_filter_remove.txt
vfprintf.txt
red_crop_trans.png
simpletext.jpg
dashedline.png
error_log
php.webp
..
simple.gd
depth1
stringup.png
imagecolortransparent.png
red_300.png
stat.txt
meta.html
paletteimage.png
imagefilledrectangle.png
simple.gd2
.
stream_filter_register.txt
simpletext.wbmp
phplogo.jpg
127.0.0.1
file.png
imageline.png
php.bmp
stream_copy_to_stream.txt
stream_filter_append.txt

3 · . ..

<?

$directory = ".";

if(opendir($directory))
{
    while(($return = readdir()) !== false)
    {
        if(($return != ".") && ($return != ".."))
        {
            echo "$return\n";
        }
    }
    closedir();
}

?>
stream_filter_prepend.txt
index.php
simpletext.xbm
my.sock
stream_filter_remove.txt
vfprintf.txt
red_crop_trans.png
simpletext.jpg
dashedline.png
error_log
php.webp
simple.gd
depth1
stringup.png
imagecolortransparent.png
red_300.png
stat.txt
meta.html
paletteimage.png
imagefilledrectangle.png
simple.gd2
stream_filter_register.txt
simpletext.wbmp
phplogo.jpg
127.0.0.1
file.png
imageline.png
php.bmp
stream_copy_to_stream.txt
stream_filter_append.txt
HomeMenu