<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.pharfileinfo.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'pharfileinfo.construct.php',
    1 => 'PharFileInfo::__construct',
    2 => 'Phar エントリオブジェクトを作成する',
  ),
  'up' => 
  array (
    0 => 'class.pharfileinfo.php',
    1 => 'PharFileInfo',
  ),
  'prev' => 
  array (
    0 => 'pharfileinfo.compress.php',
    1 => 'PharFileInfo::compress',
  ),
  'next' => 
  array (
    0 => 'pharfileinfo.decompress.php',
    1 => 'PharFileInfo::decompress',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/phar/PharFileInfo/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="pharfileinfo.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PharFileInfo::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">PharFileInfo::__construct</span> &mdash; <span class="dc-title">Phar エントリオブジェクトを作成する</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-pharfileinfo.construct-description">
  <h3 class="title">説明</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PharFileInfo::__construct</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$filename</code></span>)</div>


  <p class="para rdfs-comment">
   これは直接コールしてはいけません。PharFileInfo オブジェクトを作成するには、
   配列へのアクセスを通じて <span class="function"><a href="phar.offsetget.php" class="function">Phar::offsetGet()</a></span>
   をコールします。
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-pharfileinfo.construct-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">filename</code></dt>
     <dd>
      <p class="para">
       ファイルを取得するための完全な url。
       ファイル <code class="literal">my/file.php</code>
       の情報を phar <code class="literal">boo.phar</code> から取得したい場合は、
       このエントリは <code class="literal">phar://boo.phar/my/file.php</code> となります。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-pharfileinfo.construct-errors">
  <h3 class="title">エラー / 例外</h3>
  <p class="para">
   <a href="language.oop5.decon.php#object.construct" class="link">__construct()</a> が二度コールされた場合に
   <span class="classname"><a href="class.badmethodcallexception.php" class="classname">BadMethodCallException</a></span>、
   phar の URL がおかしかったり phar がオープンできなかったり、
   あるいはファイルが phar 内で見つからなかった場合に
   <span class="classname"><a href="class.unexpectedvalueexception.php" class="classname">UnexpectedValueException</a></span> がスローされます。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-pharfileinfo.construct-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <span class="function"><strong>PharFileInfo::__construct()</strong></span> の例</strong></p>
    <div class="example-contents"><p>
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try {<br />    </span><span style="color: #0000BB">$p </span><span style="color: #007700">= new </span><span style="color: #0000BB">Phar</span><span style="color: #007700">(</span><span style="color: #DD0000">'/path/to/my.phar'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'my.phar'</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'testfile.txt'</span><span style="color: #007700">] = </span><span style="color: #DD0000">"hi\nthere\ndude"</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$file </span><span style="color: #007700">= </span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'testfile.txt'</span><span style="color: #007700">];<br />    foreach (</span><span style="color: #0000BB">$file </span><span style="color: #007700">as </span><span style="color: #0000BB">$line </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$text</span><span style="color: #007700">) {<br />        echo </span><span style="color: #DD0000">"行番号 </span><span style="color: #0000BB">$line</span><span style="color: #DD0000">: </span><span style="color: #0000BB">$text</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />    }<br />    </span><span style="color: #FF8000">// これも動作します<br />    </span><span style="color: #0000BB">$file </span><span style="color: #007700">= new </span><span style="color: #0000BB">PharFileInfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'phar:///path/to/my.phar/testfile.txt'</span><span style="color: #007700">);<br />    foreach (</span><span style="color: #0000BB">$file </span><span style="color: #007700">as </span><span style="color: #0000BB">$line </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$text</span><span style="color: #007700">) {<br />        echo </span><span style="color: #DD0000">"行番号 </span><span style="color: #0000BB">$line</span><span style="color: #DD0000">: </span><span style="color: #0000BB">$text</span><span style="color: #DD0000">"</span><span style="color: #007700">;<br />    }<br />} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'Phar 操作に失敗しました: '</span><span style="color: #007700">, </span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は以下となります。</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">行番号 1: hi
行番号 2: there
行番号 3: dude
行番号 1: hi
行番号 2: there
行番号 3: dude</pre>
</div>
    </div>
   </div>
  </p>
 </div>


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