dir
Description
Syntax
dir(
string $directory,
?resource $context = null
): Directory|falseParameters
directory
Directory to open
context
A context stream resource.
Return
Returns an instance of Directory, or false in case of error.
Examples
1 · directory
<? $directory = "."; $return = dir($directory); print_r($return);
Directory Object
(
[path] => .
[handle] => Resource id #3
)
2 · context
<? $directory = "."; $context = stream_context_create(); $return = dir($directory, $context); print_r($return);
Directory Object
(
[path] => .
[handle] => Resource id #3
)
3 · read
<?
$directory = ".";
$return = dir($directory);
echo "path: $return->path\n"
. "handle: $return->handle\n\n";
while(($read = $return->read()) !== false)
{
echo "$read\n";
}
$return->close();
path: . handle: Resource id #3 127.0.0.1 . .. index.php my.sock