2010-09-05 41 views

回答

3

is_dir()需要一條路徑。 readdir()需要一個資源。由於opendir()方法檢索到readdir()所需的資源。

dir_handle (the parameter)

The directory handle resource previously opened with opendir() . If the directory handle is not specified, the last link opened by opendir() is assumed.

例如:

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

資源:

1

readdir預計,由opendir返回,例如資源:

$handle = opendir($myDirectory); 
if ($handle) { 
    while (($file = readdir($handle)) !== false) { 
     echo $file, '<br>'; 
    } 
} 

拿也一起來看看在這些功能的相應手冊頁的例子。

相關問題