1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-28 09:42:18 +01:00
Files
archived-doc-ru/reference/filesystem/functions/readfile.xml
2021-12-23 13:02:26 +03:00

154 lines
4.6 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: ea62fb83196997032641b50fe44420305466195e Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.readfile">
<refnamediv>
<refname>readfile</refname>
<refpurpose>Выводит файл</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>int</type><type>false</type></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 class="union"><type>resource</type><type>null</type></type><parameter>context</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Читает файл и записывает его в буфер вывода.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
Имя читаемого файла.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>use_include_path</parameter></term>
<listitem>
<para>
Если вы хотите, чтобы использовался поиск файла в <link linkend="ini.include-path">include_path</link>,
установите этот параметр в &true;.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>context</parameter></term>
<listitem>
&note.context-support;
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает количество прочитанных из файла байт в случае успешного выполнения&return.falseforfailure;
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
&fs.emits.warning.on.failure;
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Принудительная загрузка с помощью <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('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
?>
]]>
</programlisting>
&example.outputs.similar;
<mediaobject>
<alt>Диалог открытия / сохранения файла</alt>
<imageobject>
<imagedata fileref="en/reference/filesystem/figures/readfile.png"/>
</imageobject>
</mediaobject>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
<function>readfile</function> сама по себе не приводит
к каким-либо проблемам с памятью, даже при отправке больших
файлов. При возникновении ошибки превышения памяти убедитесь,
что буферизация вывода отключена с помощью
<function>ob_get_level</function>.
</para>
</note>
&tip.fopen-wrapper;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>fpassthru</function></member>
<member><function>file</function></member>
<member><function>fopen</function></member>
<member><function>include</function></member>
<member><function>require</function></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
-->