Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

DirectoryIterator::__construct

(no version information, might be only in CVS)

DirectoryIterator::__construct --  Constructs a new dir iterator from a path

Description

DirectoryIterator DirectoryIterator::__construct ( string path )

Внимание

К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.



add a note add a note User Contributed Notes
DirectoryIterator::__construct
troels
03-Apr-2007 07:34
The documentation for DirectoryIterator is sparse. I found this nice overview:
http://www.jellyandcustard.com/2006/05/18
/using-directoryiterator-to-list-files-in-php

(The above is one line, but I'm not allowed to post it like that)
springub at northclick dot de
13-Dec-2006 04:26
udvig dot ericson at gmail dot com
29-Jul-2006 07:48

In response to the comment below from udvig. The Example ist wrong, here is the right one:

<?php
$dir
= new DirectoryIterator("/tmp");
foreach (
$dir as $file) {
   if (
$file->isDot()) {
       continue;
   }
   echo
$file->getFilename() . "\n";
}
?>
ludvig dot ericson at gmail dot com
28-Jul-2006 10:48
In response to the comment below, you don't have to simulate a foreach(), DirectoryIterator obviously inherits SPL's Iterator interface, therefore:

<?php
$dir
= new DirectoryIterator("/tmp");
foreach (
$dir as $file) {
    if (
$dir->isDot()) {
        continue;
    }
    echo
$file . "\n";
}
?>
fernandobassani at gmail dot com
25-Jan-2006 10:36
We can now replace the old fashioned way of listing the content from a directory!

the old way:
<?php
if ($handle = opendir('/home/fernando/temp')) {
    while (
false !== ($file = readdir($handle))) {
        if (
$file != "." && $file != "..") {
            print
"$file <br />";
        }
    }
   
closedir($handle);
}
?>

the new way:
<?php
$dir
= new DirectoryIterator('/home/fernando/temp');
while(
$dir->valid()) {
    if(!
$dir->isDot()) {
        print
$dir->current()."<br />";
    }
   
$dir->next();
}
?>
jakob dot buchgraber at gmail dot com
04-Jan-2006 07:36
I wrote a function for finding all files in the current and in subdirectories.

The Code:
<?php
function getFiles(&$rdi,$depth=0) {

    if (!
is_object($rdi))
        return;
       
    for (
$rdi->rewind();$rdi->valid();$rdi->next()) {
       
        if (
$rdi->isDot())
            continue;
       
        if (
$rdi->isDir() || $rdi->isFile()) {
           
            for (
$i = 0; $i<=$depth;++$i)
                echo
'&nbsp;&nbsp;&nbsp;';
               
            echo
$rdi->current().'<br />';
           
            if (
$rdi->hasChildren())
               
getFiles($rdi->getChildren(),1+$depth);
        }
    }
}

getFiles(new RecursiveDirectoryIterator('.'));
?>

 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571