PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Phar::isBuffering> <Phar::hasMetaData
Last updated: Fri, 10 Oct 2008

view this page in

Phar::interceptFileFuncs

(No version information available, might be only in CVS)

Phar::interceptFileFuncsfopen、file_get_contents、opendir などの stat 関連の関数をすべて phar に横取りさせる

説明

void Phar::interceptFileFuncs ( void )

fopen()readfile()file_get_contents()opendir() などの stat 関連の関数をすべて phar に横取りさせます。 phar アーカイブ内で相対パスを指定してこれらの関数がコールされると、 それが phar アーカイブ内のファイルへのアクセスに変更されます。 絶対パスの場合は、ファイルシステム上の外部ファイルを指すものとみなされます。

この関数を使用すると、ハードディスク上で動作するように作られている PHP アプリケーションを phar アプリケーションにまとめられるようになります。

パラメータ

パラメータはありません。

返り値

例1 Phar::interceptFileFuncs() の例

<?php
Phar
::interceptFileFuncs();
include 
'phar://' __FILE__ '/file.php';
?>

phar ファイルの場所が /path/to/myphar.phar で、その中に file.phpfile2.txt が存在するものとします。 file.php にこのようなコードが含まれていた場合、

例2 Phar::interceptFileFuncs() の例

<?php
echo file_get_contents('file2.txt');
?>

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



add a note add a note User Contributed Notes
Phar::interceptFileFuncs
There are no user contributed notes for this page.

Phar::isBuffering> <Phar::hasMetaData
Last updated: Fri, 10 Oct 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites