note 106554 rejected from ref.fileinfo by thiago
| From: | thiago@php.net | Date: | Mon, 28 Nov 2011 12:08:45 +0000 |
| Subject: | note 106554 rejected from ref.fileinfo by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184729@lists.php.net to get a copy of this message | ||
Note Submitter: anderslinden at bredband dot net
----
When I read the help page for the deprecated function mime_content_type, I can see it has the
following declaration:
string mime_content_type ( string $filename )
I can also read this:
Warning
This function has been deprecated as the PECL extension Fileinfo provides the same functionality
(and more) in a much cleaner way.
So I check the help page for finfo-file, and here you see the finfo way of getting mime types for
files in a directory:
<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
foreach (glob("*") as $filename) {
echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>
So, the later method was _cleaner_? I beg to differ