0

PHPの使用に関しては、私は非常に初心者です。フォルダー上のファイルの内容をサーバーに出力しようとするこのコードが与えられましたが、特定のファイルパスに合わせてこのコードを読み取って変更する方法がわからないという問題があります。誰かがこれを手伝ってくれませんか。名前フォルダーを任意のパス名として使用できます。

<?php
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file\n";
        }
    }
    closedir($handle);
}
?> 
4

3 に答える 3

4
<?php

$dir_path = '.';  //      '.'      = current directory.
                  //      '..'     = parent directory.
                  //      '/foo'   = directory foo in the root file system
                  //      'folder' = a dir called 'folder' inside the current dir
                  //      'a/b'    = folder 'b' inside 'a' inside the current dir
                  //      '../a'   = folder 'a' inside the parent directory
if ($handle = opendir($dir_path)) {
  while (false !== ($file = readdir($handle))) {
    if ($file != "." && $file != "..") {
      echo "$file\n";
    }
  }
  closedir($handle);
}
?>
于 2009-08-12T19:09:45.673 に答える
0
<?php
$path = '.';

if ($handle = opendir($path)) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file\n";
        }
    }
    closedir($handle);
}
?>
于 2009-08-12T19:09:51.323 に答える
0

詳細な説明と例: http://www.php.net/function.opendir

于 2009-08-12T19:11:07.717 に答える