RecursiveDirectoryIterator::__construct
(PHP 5 >= 5.1.2)
RecursiveDirectoryIterator::__construct — Construye un RecursiveDirectoryIterator
Descripción
$path
[, int $flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO
] )
Construye un RecursiveDirectoryIterator()
para el path proporcionado.
Parámetros
-
path -
La ruta de el directorio a ser iterado.
-
flags -
Se pueden proporcionar flags para afectar el comportamiento de algunos métodos. Una lista de flags puede encontrarse en Constantes predefinidas FilesystemIterator. También se pueden establecer más tarde con FilesystemIterator::setFlags().
Valores devueltos
Devuelve el RecursiveDirectoryIterator recién creado.
Errores/Excepciones
Lanza una UnexpectedValueException
si el path no puede ser encontrado o este no es un directorio.
Ejemplos
Ejemplo #1 Ejemplo de RecursiveDirectoryIterator
<?php
$directorio = '/tmp';
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directorio));
$it->rewind();
while($it->valid()) {
if (!$it->isDot()) {
echo 'SubPathName: ' . $it->getSubPathName() . "\n";
echo 'SubPath: ' . $it->getSubPath() . "\n";
echo 'Key: ' . $it->key() . "\n\n";
}
$it->next();
}
?>
El resultado del ejemplo sería algo similar a:
SubPathName: fruta/manzana.xml SubPath: fruta Key: /tmp/fruta/manzana.xml SubPathName: stuff.xml SubPath: Key: /tmp/stuff.xml SubPathName: vegetales/zanahoria.xml SubPath: vegetales Key: /tmp/vegetales/zanahoria.xml
Ver también
- FilesystemIterator::__construct() - Construye un nuevo iterador filesystem
- RecursiveIteratorIterator::__construct() - Construir un objeto RecursiveIteratorIterator
- Constantes predefinidas FilesystemIterator