= 4.3.0, PHP 5, PHP 7, PHP 8)mime_content_type — 檢測(cè)文件的 MIME 類型說明mime_content_type(string $filename): string返回通過使用 magic.mime ">

mime_content_type

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

mime_content_type檢測(cè)文件的 MIME 類型

說明

mime_content_type(string $filename): string

返回通過使用 magic.mime 檢測(cè)到的文件 MIME 類型。

參數(shù)

filename

要檢測(cè)的文件名。

返回值

返回文件的 MIME 內(nèi)容類型,例如 text/plainapplication/octet-stream。 或者在失敗時(shí)返回 false。

錯(cuò)誤/異常

失敗時(shí)拋出E_WARNING警告。

范例

示例 #1 mime_content_type() 示例

<?php
echo mime_content_type('php.gif') . "\n";
echo 
mime_content_type('test.php');
?>

以上例程會(huì)輸出:

image/gif
text/plain

參見