<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Mimetype Functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="函数参考" 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=UTF-8"></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 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.mhash.html" ACCESSKEY="P" >上一页</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" >下一页</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" >LXXXVIII. Mimetype Functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN119223" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.intro" >简介</A ></H1 ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >警告</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > This extension has been deprecated as the PECL extension <A HREF="ref.fileinfo.html" >Fileinfo</A > provides the same functionality (and more) in a much cleaner way. </P ></TD ></TR ></TABLE ></DIV ><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 derived from Apache mod_mime_magic, which is itself based on the <TT CLASS="filename" >file</TT > command maintained 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 ></H1 ><P >要编译本扩展模块无需外部库文件。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.installation" >安装</A ></H1 ><P > You must compile PHP with the configure switch <CODE CLASS="option" >--with-mime-magic</CODE > to get support for mime-type functions. The extension needs a copy of the simplified <TT CLASS="filename" >magic</TT > file that is distributed with the Apache httpd. </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > The configure option has been changed from <CODE CLASS="option" >--enable-mime-magic</CODE > to <CODE CLASS="option" >--with-mime-magic</CODE > since PHP 4.3.2 </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >注意: </B > This extension is not capable of handling the fully decorated <TT CLASS="filename" >magic</TT > file that generally comes with standard Linux distro's and is supposed to be used with recent versions of <TT CLASS="filename" >file</TT > command. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Note to Win32 Users: </B > In order to use this module on a Windows environment, you must set the path to the bundled <TT CLASS="filename" >magic.mime</TT > file in your <TT CLASS="filename" >php.ini</TT >. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN119255" ></A ><P ><B >例 1. Setting the path to <TT CLASS="filename" >magic.mime</TT ></B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" >mime_magic.magicfile = "$PHP_INSTALL_DIR\magic.mime"</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > Remember to substitute the <TT CLASS="filename" >$PHP_INSTALL_DIR</TT > for your actual path to PHP in the above example. e.g. <TT CLASS="filename" >c:\php</TT > </P ></BLOCKQUOTE ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.configuration" >运行时配置</A ></H1 ><P >这些函数的行为受 <TT CLASS="filename" >php.ini</TT > 的影响。</P ><P > <DIV CLASS="table" ><A NAME="AEN119267" ></A ><P ><B >表 1. Mimetype configuration options</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><THEAD ><TR ><TH >Name</TH ><TH >Default</TH ><TH >Changeable</TH ><TH >Changelog</TH ></TR ></THEAD ><TBODY ><TR ><TD >mime_magic.debug</TD ><TD >"0"</TD ><TD >PHP_INI_SYSTEM</TD ><TD >Available since PHP 5.0.0.</TD ></TR ><TR ><TD >mime_magic.magicfile</TD ><TD >"/path/to/php/magic.mime"</TD ><TD >PHP_INI_SYSTEM</TD ><TD >Available since PHP 4.3.0.</TD ></TR ></TBODY ></TABLE ></DIV > 有关 PHP_INI_* 常量进一步的细节与定义参见<A HREF="ini.html" >附录 H</A >。 </P ><P >以下是配置选项的简要解释。</P ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><A NAME="ini.mime-magic.debug" ></A ><CODE CLASS="parameter" >mime_magic.debug</CODE > <A HREF="language.types.boolean.html" ><B CLASS="type" >bool</B ></A ></DT ><DD ><P > Enable/disable debugging. </P ></DD ><DT ><A NAME="ini.mime-magic.magicfile" ></A ><CODE CLASS="parameter" >mime_magic.magicfile</CODE > <A HREF="language.types.string.html" ><B CLASS="type" >string</B ></A ></DT ><DD ><P > The path to the magic.mime file. </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.resources" >资源类型</A ></H1 ><P >本扩展模块未定义任何资源类型。</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="mime-magic.constants" >预定义常量</A ></H1 ><P >本扩展模块未定义任何常量。</P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >目录</B ></DT ><DT ><A HREF="function.mime-content-type.html" >mime_content_type</A > -- Detect MIME Content-type for a file (deprecated)</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" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.mime-content-type.html" ACCESSKEY="N" >下一页</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" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >mime_content_type</TD ></TR ></TABLE ></DIV ></BODY ></HTML >