finfo_file

(PECL)

finfo_file -- ファイルについての情報を返す

説明

string finfo_file ( resource finfo, string file_name [, int options [, resource context]] )

class finfo {

string file ( string file_name [, int options [, resource context]] )

}

この関数は、ファイルについての情報を返すために使用します。

パラメータ

finfo

finfo_open() が返す fileinfo リソース。

file_name

調べるファイルの名前。

options

ひとつあるいは複数のFileinfo 定数の組み合わせ。

context

contexts の説明については、参照CLIII, ストリーム関数 を参照ください。

返り値

filename のテキスト表現、あるいはエラーが発生した場合に FALSE を返します。

例 1. finfo_file() の例

<?php
$finfo
= finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
    echo
finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>

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

text/html
image/gif
application/vnd.ms-excel

参考

finfo_buffer()