Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

finfo_file(3) [php man page]

FINFO_FILE(3)								 1							     FINFO_FILE(3)

finfo_file - Return information about a file

       Procedural style

SYNOPSIS
string finfo_file NULL NULL (resource $finfo, string $file_name, [int $options = FILEINFO_NONE], [resource $context]) DESCRIPTION
Object oriented style string finfo::file NULL NULL (string $file_name, [int $options = FILEINFO_NONE], [resource $context]) This function is used to get information about a file. PARAMETERS
o $finfo - Fileinfo resource returned by finfo_open(3). o $file_name - Name of a file to be checked. o $options - One or disjunction of more Fileinfo constants. o $context - For a description of contexts, refer to "Stream Functions". RETURN VALUES
Returns a textual description of the contents of the $file_name argument, or FALSE if an error occurred. EXAMPLES
Example #1 A finfo_file(3) example <?php $finfo = finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension foreach (glob("*") as $filename) { echo finfo_file($finfo, $filename) . " "; } finfo_close($finfo); ?> The above example will output something similar to: text/html image/gif application/vnd.ms-excel SEE ALSO
finfo_buffer(3). PHP Documentation Group FINFO_FILE(3)

Check Out this Related Man Page

FINFO_OPEN(3)								 1							     FINFO_OPEN(3)

finfo_open - Create a new fileinfo resource

       Procedural style

SYNOPSIS
resource finfo_open NULL ([int $options = FILEINFO_NONE], [string $magic_file]) DESCRIPTION
Object oriented style (constructor): finfo::__construct NULL ([int $options = FILEINFO_NONE], [string $magic_file]) This function opens a magic database and returns its resource. PARAMETERS
o $options - One or disjunction of more Fileinfo constants. o $magic_file - 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 VALUES
(Procedural style only) Returns a magic database resource on success or FALSE on failure. NOTES
Warning The expected magic database format changed in PHP 5.3.11 and 5.4.1. Due to this, the internal magic database was upgraded. This mostly effects code where an external magic database is used: reading an older magic file will now fail. Also, some textual repre- sentations of the mime types has changed, for instance for PHP would be "PHP script, ASCII text" instead of "PHP script text" returned. Note Generally, using the bundled magic database (by leaving $magic_file and the MAGIC environment variables unset) is the best course of action unless you specifically need a custom magic database. EXAMPLES
Example #1 Object oriented style <?php $finfo = new finfo(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension /* get mime-type for a specific file */ $filename = "/usr/local/something.txt"; echo $finfo->file($filename); ?> Example #2 Procedural style <?php $finfo = finfo_open(FILEINFO_MIME, "/usr/share/misc/magic"); // return mime type ala mimetype extension if (!$finfo) { echo "Opening fileinfo database failed"; exit(); } /* get mime-type for a specific file */ $filename = "/usr/local/something.txt"; echo finfo_file($finfo, $filename); /* close connection */ finfo_close($finfo); ?> The above example will output: text/plain; charset=us-ascii SEE ALSO
finfo_close(3). PHP Documentation Group FINFO_OPEN(3)
Man Page