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

opendir

Description

The opendir of Directory for PHP opens a directory handle.

Syntax

opendir(
    string $directory,
    ?resource $context = null
): resource|false

Parameters

directory

The directory path that is to be opened

context

For a description of the context parameter, refer to the streams section of the manual.

Return

Returns a directory handle resource on success, or false on failure

Examples

1 · directory

<?

$directory = "/";

if(opendir($directory))
{
    closedir();
}

2 · context

<?

$directory = "/";
$context = stream_context_create();

if(opendir($directory, $context))
{
    closedir();
}

3 · Return

<?

$directory = "/";

if($return = opendir($directory))
{
    closedir($return);
}

echo $return;
Resource id #3