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> <Funciones de Fileinfo
[edit] Last updated: Fri, 25 May 2012

view this page in

finfo_buffer

finfo::buffer

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

finfo_buffer -- finfo::bufferDevuelve información sobre el búfer en formato string

Descripción

Estilo por procedimientos

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

Estilo orientado a objetos

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

Esta función se usa para obtener información sobre datos binarios en formato string.

Parámetros

finfo

Recurso Fileinfo devuelto por finfo_open().

string

Contenido del fichero a ser comprobado.

options

Una o más constantes Fileinfo .

context

Valores devueltos

Devuelve una descripción contextual del argumento string o FALSE si ocurrió un error.

Ejemplos

Ejemplo #1 Ejemplo de finfo_buffer()

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

El resultado del ejemplo sería algo similar a:

application/x-sh; charset=us-ascii

Ver también



add a note add a note User Contributed Notes finfo_buffer
contact at ingnu dot fr 20-Jun-2011 02: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