php 的 mime_content_type 函数可以返回文件的类型,用法如下:

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

输出:

image/gif
text/plain
(adsbygoogle = window.adsbygoogle || []).push({});