<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.phar.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'phar.interceptfilefuncs.php',
    1 => 'Phar::interceptFileFuncs',
    2 => 'fopen、file_get_contents、opendir などの stat 関連の関数をすべて phar に横取りさせる',
  ),
  'up' => 
  array (
    0 => 'class.phar.php',
    1 => 'Phar',
  ),
  'prev' => 
  array (
    0 => 'phar.hasmetadata.php',
    1 => 'Phar::hasMetadata',
  ),
  'next' => 
  array (
    0 => 'phar.isbuffering.php',
    1 => 'Phar::isBuffering',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/phar/Phar/interceptFileFuncs.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phar.interceptfilefuncs" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::interceptFileFuncs</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Phar::interceptFileFuncs</span> &mdash; <span class="dc-title">fopen、file_get_contents、opendir などの stat 関連の関数をすべて phar に横取りさせる</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phar.interceptfilefuncs-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>Phar::interceptFileFuncs</strong></span>(): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span> や <span class="function"><a href="function.readfile.php" class="function">readfile()</a></span>、
   <span class="function"><a href="function.file-get-contents.php" class="function">file_get_contents()</a></span>、<span class="function"><a href="function.opendir.php" class="function">opendir()</a></span>
   などの stat 関連の関数をすべて phar に横取りさせます。
   phar アーカイブ内で相対パスを指定してこれらの関数がコールされると、
   それが phar アーカイブ内のファイルへのアクセスに変更されます。
   絶対パスの場合は、ファイルシステム上の外部ファイルを指すものとみなされます。
  </p>
  <p class="para">
   この関数を使用すると、ハードディスク上で動作するように作られている
   PHP アプリケーションを phar アプリケーションにまとめられるようになります。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phar.interceptfilefuncs-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   パラメータはありません。
  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-phar.interceptfilefuncs-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
  </p>
 </div>


  <div class="refsect1 examples" id="refsect1-phar.interceptfilefuncs-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>Phar::interceptFileFuncs()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">interceptFileFuncs</span><span style="color: #007700">();<br />include </span><span style="color: #DD0000">'phar://' </span><span style="color: #007700">. </span><span style="color: #0000BB">__FILE__ </span><span style="color: #007700">. </span><span style="color: #DD0000">'/file.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   phar ファイルの場所が <code class="literal">/path/to/myphar.phar</code> で、その中に
   <code class="literal">file.php</code> と
   <code class="literal">file2.txt</code> が存在するものとします。
   <code class="literal">file.php</code> にこのようなコードが含まれていた場合、
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>例2 <span class="function"><strong>Phar::interceptFileFuncs()</strong></span> の例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'file2.txt'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   通常は、PHP はカレントディレクトリの <code class="literal">file2.txt</code>
   を探します。カレントディレクトリの場所は、file.php と同じ場所かあるいは
   コマンドラインで実行した際のカレントディレクトリとなります。
   <span class="function"><strong>Phar::interceptFileFuncs()</strong></span> を使用した場合は、
   PHP はカレントディレクトリを <code class="literal">phar:///path/to/myphar.phar/</code>
   とみなし、上のコードの場合は
   <code class="literal">phar:///path/to/myphar.phar/file2.txt</code> をオープンします。
  </p>
 </div>


</div><?php manual_footer($setup); ?>