Php/docs/function.mime-content-type

提供:Dev Guides
< Php
移動先:案内検索

mime_content_type

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

mime_content_typeファイルの MIME Content-type を検出する


説明

mime_content_type ( resource|string $filename ) : string|false

magic.mime ファイルの情報を用いて、 ファイルの MIME content type を返します。


パラメータ

filename
調べるファイルへのパス。


返り値

Content type を MIME 形式で返します。 たとえば text/plain あるいは application/octet-stream のような形式です。 失敗した場合に false を返します。


エラー / 例外

失敗したときは E_WARNING が発生します。


例1 mime_content_type() の例

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

上の例の出力は以下となります。


image/gif
text/plain

参考