array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.mime-content-type.php', 1 => 'mime_content_type', ), 'up' => array ( 0 => 'ref.fileinfo.php', 1 => 'Fileinfo 函数', ), 'prev' => array ( 0 => 'function.finfo-set-flags.php', 1 => 'finfo_set_flags', ), 'next' => array ( 0 => 'class.finfo.php', 1 => 'finfo', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/fileinfo/functions/mime-content-type.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
mime_content_type — 检测文件的 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