Files
php-doc-ru/reference/phar/Phar/interceptFileFuncs.xml
Alexey Pyltsyn 8f8d4016fe Upd
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@343999 c90b9560-bf6c-de11-be94-00142212c4b1
2018-01-28 09:37:16 +00:00

108 lines
3.8 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"?>
<!-- $Revision$ -->
<!-- EN-Revision: 7418592d82d6cde8d052effd3607e5761d6c4e67 Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="phar.interceptfilefuncs" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Phar::interceptFileFuncs</refname>
<refpurpose>Указывает phar перехватывать fopen, file_get_contents, opendir и все stat-функции</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>final</modifier> <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Phar::interceptFileFuncs</methodname>
<void/>
</methodsynopsis>
<para>
Указывает phar перехватывать <function>fopen</function>, <function>readfile</function>,
<function>file_get_contents</function>, <function>opendir</function> и все
stat-функции. Если какая либо из этих функций будет вызвана из phar-архива с
относительным путем, то вызов будет модифицирован для доступа к содержимому
архива. В случае с абсолютными путями будут работать штатные функции доступа
к файловой системе.
</para>
<para>
Эта функция позволяет писать приложения работающие не привязанные к жесткому диску.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
No parameters.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>Phar::interceptFileFuncs</function></title>
<programlisting role="php">
<![CDATA[
<?php
Phar::interceptFileFuncs();
include 'phar://' . __FILE__ . '/file.php';
?>
]]>
</programlisting>
</example>
</para>
<para>
Предположим, что у нас есть <literal>/path/to/myphar.phar</literal> и в нем
содержатся файлы <literal>file.php</literal> и
<literal>file2.txt</literal>. <literal>file.php</literal> содержит такой код:
</para>
<para>
<example>
<title>Пример использования <function>Phar::interceptFileFuncs</function></title>
<programlisting role="php">
<![CDATA[
<?php
echo file_get_contents('file2.txt');
?>
]]>
</programlisting>
</example>
</para>
<para>
В обычном режиме, PHP будет искать <literal>file2.txt</literal> в текущей директории,
являющейся директорией запуска file.php, либо текущей директорией в случае
использования командной строки. <function>Phar::interceptFileFuncs</function> укажет
PHP, что текущая директория - это <literal>phar:///path/to/myphar.phar/</literal> и,
для примера выше, будет открыт файл
<literal>phar:///path/to/myphar.phar/file2.txt</literal>.
</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
-->