downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DirectoryIterator::isDir> <DirectoryIterator::getSize
[edit] Last updated: Fri, 25 May 2012

view this page in

DirectoryIterator::getType

(PHP 5)

DirectoryIterator::getType現在の DirectoryIterator アイテムのタイプを判定する

説明

public string DirectoryIterator::getType ( void )

現在の DirectoryIterator アイテムのファイルタイプを判定します。 filelink あるいは dir のいずれかとなります。

パラメータ

この関数にはパラメータはありません。

返り値

ファイルタイプを文字列で返します。 filelink あるいは dir のいずれかとなります。

例1 DirectoryIterator::getType() の例

<?php
$iterator 
= new DirectoryIterator(dirname(__FILE__));
foreach (
$iterator as $fileinfo) {
    echo 
$fileinfo->getFilename() . " " $fileinfo->getType() . "\n";
}
?>

上の例の出力は、 たとえば以下のようになります。

. dir
.. dir
apple.jpg file
banana.jpg file
example.php file
pear.jpg file

参考



add a note add a note User Contributed Notes DirectoryIterator::getType
boards at gmail dot com 09-Apr-2006 03:09
Note that this function returns the file type (e.g. "file", "dir", etc.) and not the MIME type.  To do that, you might want to use this:
<?php
for
(
 
$dir = new DirectoryIterator('/some/directory');
 
$dir->valid();
 
$dir->next()
)
{
 
$mime = mime_content_type($dir->getPathname());
}
?>

 
show source | credits | stats | sitemap | contact | advertising | mirror sites