Why is mime

I'm just curious to know why mime_content_type() is now considered deprecated.

This method for determining the mime type is much easier than the replacement Fileinfo functionality.


I guess it's because Fileinfo can return more information about files.

EDIT: Here is a replacement hack:

function _mime_content_type($filename) {
    $result = new finfo();

    if (is_resource($result) === true) {
        return $result->file($filename, FILEINFO_MIME_TYPE);
    }

    return false;
}

The method is not deprecated!

It once was incorrectly marked as deprecated in the manual, but it has been fixed https://bugs.php.net/bug.php?id=71367 on the 14th of January 2016. However, at the moment, it is still incorrectly marked deprecated in the German, Spanish and Chinese manual.

Feel free to use mime_content_type() whenever you like :).


另一种方法是传递给构造函数常量FILEINFO_MIME

$finfo = new finfo(FILEINFO_MIME);
$type  = $finfo->file('path/filename');
链接地址: http://www.djcxy.com/p/45498.html

上一篇: 从PHP中输入

下一篇: 为什么是哑剧