php8.5
Home/ Manual/ fileinfo / functions/ finfo_buffer

finfo_buffer

PHP function Edit on GitHub ✎

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

Return information about a string buffer

Description

Procedural

finfo_buffer(finfo $finfo, string $string, int $flags = FILEINFO_NONE, resource|null $context = null): string|false

Oop

finfo::buffer(string $string, int $flags = FILEINFO_NONE, resource|null $context = null): string|false

This function is used to get information about binary data in a string.

Parameters

finfo

Finfo

string

Content of a file to be checked.

flags

One or disjunction of more Fileinfo constants.

context

Return Values

Returns a textual description of the string argument, or false if an error occurred.

Changelog

VersionDescription
8.5.0The context parameter has been deprecated as it is ignored.
8.0.0context is nullable now.

Examples

A finfo_buffer() example

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

The above example will output something similar to:

output
application/x-sh; charset=us-ascii

See Also

Source: reference/fileinfo/functions/finfo-buffer.xml · from the official PHP manual (php/doc-en)