1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-24 07:02:08 +01:00
Files
archived-doc-ja/reference/phar/Phar/interceptFileFuncs.xml
2022-12-13 19:58:20 +09:00

108 lines
3.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: f03806fcd8fe03a0501bd40b6e3939ff6589a1d2 Maintainer: takagi Status: ready -->
<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>fopen、file_get_contents、opendir などの stat 関連の関数をすべて phar に横取りさせる</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis role="Phar">
<modifier>final</modifier> <modifier>public</modifier> <modifier>static</modifier> <type>void</type><methodname>Phar::interceptFileFuncs</methodname>
<void/>
</methodsynopsis>
<para>
<function>fopen</function><function>readfile</function>
<function>file_get_contents</function><function>opendir</function>
などの stat 関連の関数をすべて phar に横取りさせます。
phar アーカイブ内で相対パスを指定してこれらの関数がコールされると、
それが phar アーカイブ内のファイルへのアクセスに変更されます。
絶対パスの場合は、ファイルシステム上の外部ファイルを指すものとみなされます。
</para>
<para>
この関数を使用すると、ハードディスク上で動作するように作られている
PHP アプリケーションを phar アプリケーションにまとめられるようになります。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
パラメータはありません。
</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>
phar ファイルの場所が <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
-->