function browse_dir ($path) {
  echo "<ul>";
  $dir = dir($path);
  while ($entry = $dir->read()) {
    if (($entry != ".") && ($entry != "..")) {
      if (is_dir("$path/$entry")) {
        echo "<li> <b><font color='blue'>$entry</font></b>";
        browse_dir ("$path/$entry");
      } else {
        echo "$path/$entry";
      }
      //flush();
    }
  }
  $dir->close();
  echo "</ul>";
}browse_dir(".");

解决方案 »

  1.   

    function browse_dir ($path) {
      echo "<ul>";
      $dir = dir($path);
      while ($entry = $dir->read()) {
        if (($entry != ".") && ($entry != "..")) {
          if (is_dir("$path/$entry")) {
            echo "<li> <b><font color='blue'>$entry</font></b>";
            browse_dir ("$path/$entry");
          } else {
            echo "$path/$entry";
          }
          //flush();
        }
      }
      $dir->close();
      echo "</ul>";
    }browse_dir(".");
      

  2.   

    function &getFileListAsArray($dirname, $prefix="") {
    $filelist = array();
    if ($handle = opendir($dirname)) {
    while (false !== ($file = readdir($handle))) {
    if (!preg_match("/^[.]{1,2}$/",$file) && !is_dir($file)) {
    $file = $prefix.$file;
    $filelist[$file]=$file;
    }
    }
    closedir($handle);
    asort($filelist);
    reset($filelist);
    }
    return $filelist;
      

  3.   

    我的更好 :)
    列举指定目录的所有文件  包括子目录的文件

    $FileCount = 0; //文件个数 
    $DirectoryCount = 0; //目录个数 
    function FCount($Path) 

    global $FileCount,$DirectoryCount; 
        $Handle = opendir($Path); 
        while($File = readdir($Handle)) 
        { 
            if(filetype($Path.$File) != 'dir') 
            { 
                echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$File(".filesize($Path.$File).")"; 
                            echo "<br>"; 
                $FileCount++; 
            } 
            if($File !='.' && $File !='..' && filetype($Path.$File)=='dir') 
            {             echo "------------------------------------------------------------<br><font color=blue>$File</font><br>"; 
                $DirectoryCount++; 
                FCount($Path."$File/"); 
    echo "------------------------------------------------------------<br>";
            } 
        } 
        closedir($Handle); 

    FCount($url); 
    echo "<br>请您注意脚本程序30秒钟超时警告<br><br>目录个数……………………$DirectoryCount<br>----文件个数……………………$FileCount<br>"; 
    ?> 
      

  4.   

    phpteam(好无聊) 的不错。我侧了一下
      

  5.   

    <?
    class path {
          var $path;
          var $files;
          var $file_num = 0;
          var $err = false;
          var $info = '';      function path($PATH = '.') {
                   $this->path = $PATH;
                   $this->file_num = 0;
                   $this->err = false;
                   $this->info = '';
          }      function init($PATH = '.') {
                   $this->path = $PATH;
                   $this->file_num = 0;
                   $this->err = false;
                   $this->info = '';
          }      function read($PATH = '') {
                   if ($PATH == '') {
                        $PATH = $this->path;
                   } else {
                     $this->path = $PATH;
                   }
                   if ($PATH != '') {
                        if ($HANDLE = opendir($PATH)) {
                             while ($file = readdir($HANDLE)) {
                                     $this->files[$this->file_num] = $file;
                                     $this->file_num ++;
                             }
                             closedir($HANDLE);
                        } else {
                          $this->err = true;
                          $this->info = '&Icirc;&THORN;·¨&acute;ò&iquest;&ordf;&Icirc;&Auml;&frac14;&thorn;&frac14;&ETH;&pound;&not;&raquo;ò&Icirc;&Auml;&frac14;&thorn;&frac14;&ETH;&sup2;&raquo;&acute;&aelig;&Ocirc;&Uacute;&iexcl;&pound;';
                        }
                   } else {
                     $this->err = true;
                     $this->info = '&Icirc;&acute;&Ouml;&cedil;&para;¨&Icirc;&Auml;&frac14;&thorn;&frac14;&ETH;&iexcl;&pound;';
                   }
          }
    };
    ?>
      

  6.   

    to: phpteam(好无聊) ,读出来了,可是怎样解决30秒的执行时间呢,好像最多执行30秒,在哪可修改?
      

  7.   

    set_time_limit
    (PHP 3, PHP 4 )set_time_limit -- Limits the maximum execution timeDescription
    void set_time_limit ( int seconds)Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the configuration file. If seconds is set to zero, no time limit is imposed. When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. set_time_limit() has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the configuration file. 注: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), the sleep() function, database queries, etc. is not included when determining the maximum time that the script has been running. --------------------------------------------
    用这个函数. set_time_limit(0)