mime_content_type 检测文件的 MIME 类型

发表日期:2021-07-01 08:55:35 | 来源: | | 浏览(750) 分类:Fileinfo 函数

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/plainapplication/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

参见

  • finfo_file() - 别名 finfo_file()
  • finfo_buffer() - 别名 finfo_buffer()

集速网 copyRight © 2015-2022 宁ICP备15000399号-1 宁公网安备 64010402001209号
与其临渊羡鱼,不如退而结网
欢迎转载、分享、引用、推荐、收藏。