以下の内容はhttps://www.weblio.jp/content/opendirより取得しました。


PHP Documentation GroupPHP Documentation Group

opendir

(PHP 4, PHP 5)
opendir — ディレクトリハンドルをオープンする

説明

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

パラメータ

path
オープンするディレクトリのパス。
context
context パラメータの詳細については マニュアルのストリーム を参照ください。

返り値

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

変更履歴

バージョン説明
5.0.0 pathftp:// URL ラッパをサポートします。
4.3.0 path に、ディレクトリの一覧表示をサポートする URL を指定することが可能です。しかし、PHP 4 では file:// URL ラッパのみをサポートしています。

例 477. opendir() の例
<?php
$dir = "/etc/php5/";

// 既知のディレクトリをオープンし、その内容を読み込みます。
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
           echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
       }
       closedir($dh);
   }
}
?>
上の例の出力は、たとえば 以下のようになります。

filename: . : filetype: dir
filename: .. : filetype: dir
filename: apache : filetype: dir
filename: cgi : filetype: dir
filename: cli : filetype: dir

    


参考

is_dir()
readdir()
Dir





固有名詞の分類

PHP bcmul  echo  opendir  acos  gmmktime



以上の内容はhttps://www.weblio.jp/content/opendirより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14