Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

finfo_set_flags

Description

The finfo_set_flags of Fileinfo for PHP sets libmagic configuration options.

Syntax

finfo_set_flags(
    finfo $finfo,
    int $flags
): bool

Parameters

finfo

An finfo instance, returned by finfo_open().

flags

One or disjunction of more Fileinfo constants.

Return

Returns true on success or false on failure.

Examples

1 · finfo flags

<?

$finfo = finfo_open();

    if($finfo === false)
    {
        die("finfo_open");
    }

    $flags = FILEINFO_MIME_TYPE;

    $return = finfo_set_flags($finfo, $flags);

    var_export($return);

finfo_close($finfo);

?>
true

2 · finfo_file

<?

$finfo = finfo_open();

    if($finfo === false)
    {
        die("finfo_open");
    }

    $flags = FILEINFO_MIME_TYPE;

    finfo_set_flags($finfo, $flags);

    $filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/txt/1.txt";

    echo finfo_file($finfo, $filename);

finfo_close($finfo);

?>
text/plain
HomeMenu