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

finfo_open

Description

The finfo_open of Fileinfo for PHP creates a new finfo instance.

Syntax

finfo_open(
    int $flags = FILEINFO_NONE,
    ?string $magic_database = null
): finfo|false

Parameters

flags

One or disjunction of more Fileinfo constants.

magic_database

Name of a magic database file, usually something like /path/to/magic.mime. If not specified, the MAGIC environment variable is used. If the environment variable isn't set, then PHP's bundled magic database will be used.

Passing null or an empty string will be equivalent to the default value.

Return

Returns an finfo instance on success, or false on failure.

Examples

1 · void

<?

$return = finfo_open();

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

    var_dump($return);

finfo_close($return);

?>
object(finfo)#1 (0) {
}

2 · flags

<?

$flags = FILEINFO_MIME;

$return = finfo_open($flags);

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

    var_dump($return);

finfo_close($return);

?>
object(finfo)#1 (0) {
}

3 · magic_database

<?

$flags = FILEINFO_MIME;
$magic_database = $_ENV["MAGIC"];

$return = finfo_open($flags, $magic_database);

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

    var_dump($return);

finfo_close($return);

?>
object(finfo)#1 (0) {
}
HomeMenu