PharFileInfo::__construct

(no version information, might be only in CVS)

PharFileInfo::__construct -- Phar エントリオブジェクトを作成する

説明

void PharFileInfo::__construct ( string entry )

これは直接コールしてはいけません。PharFileInfo オブジェクトを作成するには、 配列へのアクセスを通じて Phar::offsetGet() をコールします。

パラメータ

entry

ファイルを取得するための完全な url。 ファイル my/file.php の情報を phar boo.phar から取得したい場合は、 このエントリは phar://boo.phar/my/file.php となります。

エラー / 例外

__construct() が二度コールされた場合に BadMethodCallException、 phar の URL がおかしかったり phar がオープンできなかったり、 あるいはファイルが phar 内で見つからなかった場合に UnexpectedValueException がスローされます。

例 1. PharFileInfo::__construct() の例

<?php
$p
= new Phar('/path/to/my.phar', 0, 'my.phar');
$p['testfile.txt'] = "hi\nthere\ndude";
$file = $p['testfile.txt'];
foreach (
$file as $line => $text) {
    echo
"行番号 $line: $text";
}
// これも動作します
$file = new PharFileInfo('phar:///path/to/my.phar/testfile.txt');
foreach (
$file as $line => $text) {
    echo
"行番号 $line: $text";
}
?>

上の例の出力は以下となります。

行番号 1: hi
行番号 2: there
行番号 3: dude
行番号 1: hi
行番号 2: there
行番号 3: dude