xref: /PHP-7.1/ext/fileinfo/fileinfo.php (revision 06fdf359)
1<?php
2if(!extension_loaded('fileinfo')) {
3	dl('fileinfo.' . PHP_SHLIB_SUFFIX);
4}
5if(!extension_loaded('fileinfo')) {
6	die("fileinfo extension is not available, please compile it.\n");
7}
8
9// normal operation
10$res = finfo_open(FILEINFO_MIME); /* return mime type ala mimetype extension */
11$files = glob("*");
12foreach ($files as $file) {
13	echo finfo_file($res, $file) . "\n";
14}
15finfo_close($res);
16
17// OO mode
18/*
19 * FILEINFO_PRESERVE_ATIME - if possible preserve the original access time
20 * FILEINFO_SYMLINK - follow symlinks
21 * FILEINFO_DEVICES - look at the contents of blocks or character special devices
22 * FILEINFO_COMPRESS - decompress compressed files
23 */
24$fi = new finfo(FILEINFO_PRESERVE_ATIME|FILEINFO_SYMLINK|FILEINFO_DEVICES|FILEINFO_COMPRESS);
25$files = glob("*");
26foreach ($files as $file) {
27        echo $fi->buffer(file_get_contents($file)) . "\n";
28}
29?>
30