note 106554 added to ref.fileinfo
| From: | anderslinden at bredband dot net | Date: | Fri, 18 Nov 2011 09:09:20 +0000 |
| Subject: | note 106554 added to ref.fileinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184556@lists.php.net to get a copy of this message | ||
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
----
Server IP: 69.147.83.197
Probable Submitter: 62.168.150.34
----
Manual Page -- http://www.php.net/manual/en/ref.fileinfo.php
Edit -- https://master.php.net/note/edit/106554
Del: integrated -- https://master.php.net/note/delete/106554/integrated
Del: useless -- https://master.php.net/note/delete/106554/useless
Del: bad code -- https://master.php.net/note/delete/106554/bad+code
Del: spam -- https://master.php.net/note/delete/106554/spam
Del: non-english -- https://master.php.net/note/delete/106554/non-english
Del: in docs -- https://master.php.net/note/delete/106554/in+docs
Del: other reasons-- https://master.php.net/note/delete/106554
Reject -- https://master.php.net/note/reject/106554
Search -- https://master.php.net/manage/user-notes.php