views:

632

answers:

2

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.

+1  A: 

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;
}
Alix Axel
Although this is possibly true, the fact remains that it is much harder to configure and takes more effort to use. Could it not remain un-depricated and just utilize the finfo functions?
Josiah
I use a similar hack to determine the file-type of files but firstly use the mime_content_type() method because I have found it to be more reliable across servers. However i'm still perplexed as to why this method is now deprecated?
Josiah
I agree with both your comments, they could have just rewrited the function to rely on the finfo class.
Alix Axel
A: 

What if you don't even have finfo support nor mime-magic support, at least like I do with this precompiled plesk environment, why do they want to make life harder php is not supposed to be like ASP.

uniacid
Then you're in pretty deep, you could try using either the command line tools (if you're running *nix) or rely on the mime type that the user sends. Only use the second option if you trust your users, and never trust your users :P. A third option would be to rely on the file extension, but that again gets you to the problem of trusting your users.
Josiah