dir

dir -- ディレクトリ・クラス

説明

class dir {

dir ( string directory)

string path

resource handle

string read ( void )

void rewind ( void )

void close ( void )

}

ディレクトリを読むための疑似オブジェクト指向の機構です。 指定した directory がオープンされます。 いったんディレクトリがオープンされると、2 つのプロパティを使用 できるようになります。handle プロパティは、readdir (), rewinddir(), closedir() のような他のディレクトリ関数と組み合わせて 使用可能です。path プロパティには、オープンするディレクトリのパス がセットされます。read, rewind, close の3種類のメソッドが 使用できます。

Please note the fashion in which dir()'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 Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop.

例 1. dir() の例

$d = dir("/etc");
echo "Handle: ".$d->handle."<br>\n";
echo "Path: ".$d->path."<br>\n";
while (false !== ($entry = $d->read())) {
    echo $entry."<br>\n";
}
$d->close();

注意: 読み込みにより返されるディレクトリエントリの順番は、システムに依 存します。

注意: This defines the internal class Directory, meaning that you will not be able to define your own classes with that name. For a full list of predefined classes in PHP, please see Predefined Classes.