<HTML ><HEAD ><TITLE >Mimetype Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="mhash" HREF="function.mhash.html"><LINK REL="NEXT" TITLE="mime_content_type" HREF="function.mime-content-type.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.mhash.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.mime-content-type.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.mime-magic" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >LVII. Mimetype Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN51539" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.intro" ></A >Introduction</H1 ><P > The functions in this module try to guess the content type and encoding of a file by looking for certain <SPAN CLASS="emphasis" ><I CLASS="emphasis" >magic</I ></SPAN > byte sequences at specific positions within the file. While this is not a bullet proof approach the heuristics used do a very good job. </P ><P > This extension is derivated from Apache mod_mime_magic, which is itself based on the <TT CLASS="filename" >file</TT > command maintaind by Ian F. Darwin. See the source code for further historic and copyright information. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.requirements" ></A >Requirements</H1 ><P >No external libraries are needed to build this extension.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.installation" ></A >Installation</H1 ><P > You must compile PHP with the configure switch <TT CLASS="option" >--enable-mime-magic</TT > to get support for mime-type functions. The extension needs a copy of the <TT CLASS="filename" >magic.mime</TT > as distributed with the <TT CLASS="filename" >file</TT > command. This file also part of most recent Linux distributions and usually stored in the <TT CLASS="filename" >/usr/share/misc</TT > directory. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.configuration" ></A >Runtime Configuration</H1 ><P > The behaviour of these functions is affected by settings in <TT CLASS="filename" >php.ini</TT >. </P ><P > <DIV CLASS="table" ><A NAME="AEN51561" ></A ><P ><B >Table 1. Mimetype configuration options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Name</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Default</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Changeable</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >mime_magic.magicfile</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >"/usr/share/misc/magic.mime"</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >PHP_INI_SYSTEM</TD ></TR ></TBODY ></TABLE ></DIV > For further details and definition of the PHP_INI_* constants see <A HREF="function.ini-set.html" ><B CLASS="function" >ini_set()</B ></A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.resources" ></A >Resource Types</H1 ><P >This extension has no resource types defined.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.constants" ></A >Predefined Constants</H1 ><P >This extension has no constants defined.</P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.mime-content-type.html" >mime_content_type</A > -- Detect MIME Content-type for a file</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.mhash.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.mime-content-type.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >mhash</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >mime_content_type</TD ></TR ></TABLE ></DIV ></BODY ></HTML >