finfo_file
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 の説明については、ストリーム を参照ください。
返り値
filename のテキスト表現、あるいはエラーが発生した場合に FALSE を返します。例
例 585. 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() |
- finfo_fileのページへのリンク