opendir

(PHP 3, PHP 4 )

opendir -- ディレクトリ・ハンドルのオープン

説明

resource opendir ( string path)

ディレクトリ・ハンドルをオープンします。この関数は、この後、 closedir() , readdir() , rewinddir() 関数コールで使用されます。

path が有効なディレクトリでないかまたは権 限が制限されているかファイルシステムのエラーによりディレクトリが オープンできない場合、 opendir() FALSE を返し、 PHPエラーを生成します。 opendir() のこのエラー出 力は、関数名の前に `@' を付けることにより抑制できます。

例 1 opendir() の例

 ?php

if ($dir = @opendir("/tmp")) {
  while (($file = readdir($dir)) !== false) {
    echo "$file\n";
  }  
  closedir($dir);
}

?