Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: finfo_open - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

finfo_set_flags" width="11" height="7"/> <finfo_file
Last updated: Sun, 23 Sep 2007

view this page in

finfo_open,

(PECL fileinfo:0.1-1.0.4)

finfo_open, finfo->__construct() — 新しい fileinfo リソースを作成する

説明

手続き型

resource finfo_open ( [int $options [, string $arg]] )

オブジェクト指向型 (コンストラクタ)

class finfo {
__construct ( [int $options [, string $magic_file]] )
}

この関数は、magic データベースをオープンしてそのリソースを返します。

パラメータ

options

ひとつあるいは複数のFileinfo 定数の組み合わせ。

magic_file

magic データベースファイルの名前。通常は /path/to/magic.mime のようになります。 指定されなかった場合は、環境変数 MAGIC の値が使用されます。この環境変数も設定されていない場合、 /usr/share/misc/magic をデフォルトで使用します。 必要に応じて、.mime.mgc が追加されます。

返り値

成功した場合に magic データベースリソース、失敗した場合に FALSE を返します。

例 608. オブジェクト指向型

<?php
$finfo
= new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension

if (!$finfo) {
    echo
"fileinfo データベースのオープンに失敗しました";
    exit();
}

/* 指定したファイルの mime タイプを取得します */
$filename = "/usr/local/something.txt";
echo
$finfo->file($filename);

/* 接続を閉じます */
$finfo->close();
?>

例 609. 手続き型

<?php
$finfo
= finfo_open(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension

if (!$finfo) {
    echo
"fileinfo データベースのオープンに失敗しました";
    exit();
}

/* 指定したファイルの mime タイプを取得します */
$filename = "/usr/local/something.txt";
echo
finfo_file($finfo, $filename);

/* 接続を閉じます */
finfo_close($finfo);
?>

上の例の出力は以下となります。


text/plain

  

参考

finfo_close()



finfo_set_flags" width="11" height="7"/> <finfo_file
Last updated: Sun, 23 Sep 2007
 
add a note add a note User Contributed Notes
finfo_open
aldoh at cableonda dot net
20-Sep-2007 10:43
Here is the exact link for Win32user to the file binary package:

http://sourceforge.net/project/showfiles.php?
group_id=23617&package_id=18878
cs at tequila dot co dot jp
04-Jun-2007 01:13
the "close" method does not exists, as it is the default deconstructior there is no need to call it.
tularis at php dot net
07-May-2007 04:55
On Windows systems people might find that this always returns "application/x-dpkg".
There are 2 ways of solving this problem:
1. Get the mime-magic database file from GnuWin32 at <" target="_blank">http://sourceforge.net/projects/gnuwin32/>
2. You can manually "fix" the mime-magic file by editing it and escaping all lines starting with !, thus changing each one to \!

finfo_set_flags" width="11" height="7"/> <finfo_file
Last updated: Sun, 23 Sep 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites