opendir

(PHP 3, PHP 4 >= 4.0.0)

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

説明

int opendir (string path)

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

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

例 1opendir() の例


<?php

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

?>