循环遍历目录以查看哪些是可写的


loop through dirs to see which are writable

<?php
$iterator = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator('./'), 
            RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file) {
    if($file->isDir()) {
        echo "'n" . strtoupper($file->getRealpath()), PHP_EOL;
    }
}
?>

以上是我到目前为止所拥有的。我希望通过目录和子目录,看看哪些是可写的。

你试过使用 isWritable(( 方法吗?

<?php
$iterator = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator('./'), 
            RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $file) {
    if($file->isDir()) {
        echo "'n" . strtoupper($file->getRealpath()), PHP_EOL;
        if($file->isWritable()) {
            echo "directory is writable'n";
        }
    }
}
?>

http://www.php.net/manual/en/splfileinfo.iswritable.php