mime_content_type
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
mime_content_type — 檢測檔案的 MIME 型別
說明
mime_content_type(string
$filename
): string返回通過使用 magic.mime 檢測到的檔案 MIME 型別。
參數
-
filename
-
要檢測的檔名。
返回值
返回檔案的 MIME 內容型別,例如
text/plain
或 application/octet-stream
。 或者在失敗時返回 false
。
錯誤/異常
失敗時拋出E_WARNING
警告。
範例
示例 #1 mime_content_type() 示例
<?php
echo mime_content_type('php.gif') . "\n";
echo mime_content_type('test.php');
?>
以上例程會輸出:
image/gif text/plain