finfo_file

finfo::file

(PHP >= 5.3.0, PECL fileinfo >= 0.1.0)

finfo_file -- finfo::file返回一个文件的信息

说明

过程化风格

finfo_file ( resource $finfo , string $file_name = NULL [, int $options = FILEINFO_NONE [, resource $context = NULL ]] ) : string

面向对象风格

public finfo::file ( string $file_name = NULL [, int $options = FILEINFO_NONE [, resource $context = NULL ]] ) : string

本函数用来获取一个文件的信息。

参数

finfo

finfo_open() 函数所返回的 fileinfo 资源。

file_name

要检查的文件名。

options

一个 Fileinfo 常量 或多个 Fileinfo 常量 进行逻辑或运算。

context

关于 contexts 的更多描述,请参考 Stream 函数

返回值

返回 file_name 参数指定的文件信息。 发生错误时返回 FALSE

范例

Example #1 finfo_file() 例程

<?php
$finfo 
finfo_open(FILEINFO_MIME_TYPE); // 返回 mime 类型
foreach (glob("*") as $filename) {
    echo 
finfo_file($finfo$filename) . "\n";
}
finfo_close($finfo);
?>

以上例程的输出类似于:

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

参见