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

search for in the

finfo_close> <Fileinfo 関数
[edit] Last updated: Fri, 10 Feb 2012

view this page in

finfo_buffer

finfo::buffer

(PHP 5 >= 5.3.0, PECL fileinfo >= 0.1.0)

finfo_buffer -- finfo::buffer文字列バッファの情報を返す

説明

手続き型

string finfo_buffer ( resource $finfo , string $string = NULL [, int $options = FILEINFO_NONE [, resource $context = NULL ]] )

オブジェクト指向型

string finfo::buffer ( string $string = NULL [, int $options = FILEINFO_NONE [, resource $context = NULL ]] )

この関数は、バイナリデータの情報を文字列形式で返すために使用します。

パラメータ

finfo

finfo_open() が返す fileinfo リソース。

string

調べるファイルの内容。

options

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

context

返り値

string のテキスト表現、あるいはエラーが発生した場合に FALSE を返します。

例1 finfo_buffer() の例

<?php
$finfo 
= new finfo(FILEINFO_MIME);
echo 
$finfo->buffer($_POST["script"]) . "\n";
?>

上の例の出力は、 たとえば以下のようになります。

application/x-sh; charset=us-ascii

参考



add a note add a note User Contributed Notes finfo_buffer
contact at ingnu dot fr 20-Jun-2011 11:22
You can easily check mime type of an internet resource using this code :

<?php
function getUrlMimeType($url) {
   
$buffer = file_get_contents($url);
   
$finfo = new finfo(FILEINFO_MIME_TYPE);
    return
$finfo->buffer($buffer);
}
?>

I'm using it to detect if an url given by a user is a HTML page (so I do some stuff with the HTML) or a file on Internet (so I show an icon accordingly to the mime type).

 
show source | credits | stats | sitemap | contact | advertising | mirror sites