Friday, October 10, 2025
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
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7101 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS