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
32711 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7083 POSTS0 COMMENTS
Nicole Veronica
12222 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12307 POSTS0 COMMENTS
Shaida Kate Naidoo
7201 POSTS0 COMMENTS
Ted Musemwa
7461 POSTS0 COMMENTS
Thapelo Manthata
7185 POSTS0 COMMENTS
Umr Jansen
7169 POSTS0 COMMENTS