PHP.nl

dir

dir

Return an instance of the Directory class

 **dir** string $directory  $context

A pseudo-object-oriented mechanism for reading a directory. The given is opened. directory

directoryDirectory to open

context Returns an instance of , or false in case of error. Directory

Voorbeeld: example

 Please note the fashion in which '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  for more information) false since
 otherwise, any directory entry whose name evaluates to false will
 stop the loop.
`Directory::read`Comparison Operators
<?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();
?>
Handle: Resource id #2
Path: /etc/php5
.
..
apache
cgi
cli

Opmerking: > The order in which directory entries are returned by the read method is system-dependent.