mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 19:08:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@303721 c90b9560-bf6c-de11-be94-00142212c4b1
154 lines
4.1 KiB
XML
154 lines
4.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.finfo-open" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>finfo_open</refname>
|
|
<refname>finfo->__construct</refname>
|
|
<refpurpose>Create a new fileinfo resource</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<para>&style.procedural;</para>
|
|
<methodsynopsis role="procedural">
|
|
<type>resource</type><methodname>finfo_open</methodname>
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>FILEINFO_NONE</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>magic_file</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>&style.oop; (constructor):</para>
|
|
<classsynopsis>
|
|
<ooclass><classname>finfo</classname></ooclass>
|
|
<constructorsynopsis>
|
|
<methodname>__construct</methodname>
|
|
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>FILEINFO_NONE</initializer></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>magic_file</parameter><initializer>&null;</initializer></methodparam>
|
|
</constructorsynopsis>
|
|
</classsynopsis>
|
|
<para>
|
|
This function opens a magic database and returns its resource.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>options</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
One or disjunction of more <link linkend="fileinfo.constants">Fileinfo
|
|
constants</link>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>magic_file</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Name of a magic database file, usually something like
|
|
<filename>/path/to/magic.mime</filename>. If not specified,
|
|
the <literal>MAGIC</literal> environment variable is used. If this variable
|
|
is not set either, <filename>/usr/share/misc/magic</filename> is used by default.
|
|
A <literal>.mime</literal> and/or <literal>.mgc</literal> suffix is added if
|
|
needed.
|
|
</para>
|
|
<para>
|
|
Passing NULL or an empty string will be equivalent to the default value.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns a magic database resource on success&return.falseforfailure;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title>Object oriented style</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$finfo = new finfo(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($filename);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example>
|
|
<title>Procedural style</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
text/plain; charset=us-ascii
|
|
]]>
|
|
</screen>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>finfo_close</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|