Fileinfo Functions

XXXVII. Fileinfo Functions

Introduction

Warning

This extension is EXPERIMENTAL. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk.

The functions in this module try to guess the content type and encoding of a file by looking for certain magic byte sequences at specific positions within the file. While this is not a bullet proof approach the heuristics used do a very good job.

Requirements

magic_open library is needed to build this extension.

Installation

A short installation note: just type
$ pear install fileinfo
in your console.

Runtime Configuration

This extension has no configuration directives defined in php.ini.

Resource Types

There is one resource used in Fileinfo extension: a magic database descriptor returned by finfo_open().

Predefined Constants

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

FILEINFO_NONE (integer)

No special handling.

FILEINFO_SYMLINK (integer)

Follow symlinks.

FILEINFO_MIME (integer)

Return a mime string, instead of a textual description.

FILEINFO_COMPRESS (integer)

Decompress compressed files.

FILEINFO_DEVICES (integer)

Look at the contents of blocks or character special devices.

FILEINFO_CONTINUE (integer)

Return all matches, not just the first.

FILEINFO_PRESERVE_ATIME (integer)

If possible preserve the original access time.

FILEINFO_RAW (integer)

Don't translate unprintable characters to a \ooo octal representation.

Table of Contents
finfo_buffer -- Return information about a string buffer
finfo_close -- Close fileinfo resource
finfo_file -- Return information about a file
finfo_open -- Create a new fileinfo resource
finfo_set_flags -- Set libmagic configuration options
© Copyright 2003-2014 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.