finfo_file
finfo::file
(PHP >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0)
finfo_file -- finfo::file — 返回一個檔案的資訊
說明
過程化風格
finfo_file(
resource
string
int
resource
): string
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
。
範例
示例 #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