php-doc-en/reference/filesystem/functions/readfile.xml
Jakub Vrana a9b26c34e4 Display language constructs without parentheses
Side effect of this change is that include, require and return are now properly linked. They weren't because they don't live inside <refentry> so PhD doesn't know about them.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@324522 c90b9560-bf6c-de11-be94-00142212c4b1
2012-03-25 08:39:30 +00:00

147 lines
4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.readfile">
<refnamediv>
<refname>readfile</refname>
<refpurpose>Outputs a file</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>readfile</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>use_include_path</parameter><initializer>false</initializer></methodparam>
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
</methodsynopsis>
<para>
Reads a file and writes it to the output buffer.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
The filename being read.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>use_include_path</parameter></term>
<listitem>
<para>
You can use the optional second parameter and set it to &true;, if
you want to search for the file in the <link
linkend="ini.include-path">include_path</link>, too.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
<para>
A context stream <type>resource</type>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the number of bytes read from the file. If an error
occurs, &false; is returned and unless the function was called as
@<function>readfile</function>, an error message is printed.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Forcing a download using <function>readfile</function></title>
<programlisting role="php">
<![CDATA[
<?php
$file = 'monkey.gif';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>
]]>
</programlisting>
&example.outputs.similar;
<mediaobject>
<alt>Open / Save dialogue</alt>
<imageobject>
<imagedata fileref="en/reference/filesystem/figures/readfile.png"/>
</imageobject>
</mediaobject>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&tip.fopen-wrapper;
&note.context-support;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>fpassthru</function></member>
<member><function>file</function></member>
<member><function>fopen</function></member>
<member><link linkend="function.include"><literal>include</literal></link></member>
<member><link linkend="function.require"><literal>require</literal></link></member>
<member><function>virtual</function></member>
<member><function>file_get_contents</function></member>
<member><xref linkend="wrappers"/></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
-->