Sunday, June 14, 2026
HomeLanguagesPHP finfo_buffer() Function

PHP finfo_buffer() Function

The finfo_buffer() is an inbuilt function in PHP that returns information about a string buffer.

Syntax:

  • Procedural Style:
    string | false finfo_uffer(
        string $string, 
        int $flags = FILEINFO_NONE, 
        ?resource $context = null
    )
  • Object-Oriented Style:
    public finfo::buffer(
        string $string, 
        int $flags = FILEINFO_NONE, 
        ?resource $context = null
    ): string | false

Parameters: This function accepts three parameters that are described below:

  • string: It contains the content of a file that to be checked.
  • flags: It contains one or disjunction of more Fileinfo constants.
  • finfo: It contains a finfo instance that is returned by finfo_open() function.

Return Value: This function returns a textual description of the string argument, otherwise, it will return false.

Example 1: This example describes the finfo_buffer() function.

PHP




<?php
$finfo = new finfo(FILEINFO_MIME);
echo $finfo->buffer("./index.php") . "\n";
?>


Output:

text/plain; charset=us-ascii

Example 2: This example describes the finfo_buffer() function.

PHP




<?php
$finfo = new finfo(FILEINFO_MIME);
echo finfo_buffer($finfo,"./index.php") . "\n";
?>


Output:

text/plain; charset=us-ascii

Reference: https://www.php.net/manual/en/function.finfo-buffer.php

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS