(PHP >= 5.3.0, PHP 7, PHP 8, PECL fileinfo >= 0.1.0)
finfo_file -- finfo::file — Return information about a file
Процедурний стиль
$finfo,$filename,$flags = FILEINFO_NONE,$context = nullОб'єктно-орієнтований стиль
$filename, int $flags = FILEINFO_NONE, ?resource $context = null): string|falseThis function is used to get information about a file.
finfoПримірник finfo, що повертається функцією finfo_open().
filenameName of a file to be checked.
flagsOne or disjunction of more Fileinfo constants.
context
For a description of contexts, refer to Stream Функції.
Returns a textual description of the contents of the
filename argument, or false if an error occurred.
| Версія | Опис |
|---|---|
| 8.1.0 |
Тепер параметр finfo має бути примірником
finfo, а не resource, як раніше.
|
| 8.0.0 |
context is nullable now.
|
Приклад #1 A finfo_file() example
<?php
$finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type aka mimetype extension
foreach (glob("*") as $filename) {
echo finfo_file($finfo, $filename) . "\n";
}
finfo_close($finfo);
?>Поданий вище приклад виведе щось схоже на:
text/html image/gif application/vnd.ms-excel