<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'phar.offsetget.php',
    1 => 'Phar::offsetGet',
    2 => 'Gets a PharFileInfo object for a specific file',
  ),
  'up' => 
  array (
    0 => 'class.phar.php',
    1 => 'Phar',
  ),
  'prev' => 
  array (
    0 => 'phar.offsetexists.php',
    1 => 'Phar::offsetExists',
  ),
  'next' => 
  array (
    0 => 'phar.offsetset.php',
    1 => 'Phar::offsetSet',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/Phar/offsetGet.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phar.offsetget" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::offsetGet</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">Phar::offsetGet</span> &mdash; <span class="dc-title">Gets a <span class="classname"><a href="class.pharfileinfo.php" class="classname">PharFileInfo</a></span> object for a specific file</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-phar.offsetget-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Phar::offsetGet</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$localName</code></span>): <span class="type"><a href="class.splfileinfo.php" class="type SplFileInfo">SplFileInfo</a></span></div>


  <p class="para rdfs-comment">
   This is an implementation of the <span class="interfacename"><a href="class.arrayaccess.php" class="interfacename">ArrayAccess</a></span>
   interface allowing direct manipulation of the contents of a Phar archive using
   array access brackets. <span class="methodname"><strong>Phar::offsetGet()</strong></span> is used 
   for retrieving files from a Phar archive.
  </p>

 </div>

 <div class="refsect1 parameters" id="refsect1-phar.offsetget-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">localName</code></dt>
     <dd>
      <p class="para">
       The filename (relative path) to look for in a Phar.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-phar.offsetget-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   A <span class="classname"><a href="class.pharfileinfo.php" class="classname">PharFileInfo</a></span> object is returned that can be used to
   iterate over a file&#039;s contents or to retrieve information about the current file.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.offsetget-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   This method throws <span class="classname"><a href="class.badmethodcallexception.php" class="classname">BadMethodCallException</a></span> if the file
   does not exist in the Phar archive.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-phar.offsetget-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>Phar::offsetGet()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     As with all classes that implement the <span class="classname"><a href="class.arrayaccess.php" class="classname">ArrayAccess</a></span>
     interface, <span class="methodname"><strong>Phar::offsetGet()</strong></span> is automatically
     called when using the <code class="literal">[]</code> angle bracket operator.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$p </span><span style="color: #007700">= new </span><span style="color: #0000BB">Phar</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">) . </span><span style="color: #DD0000">'/myphar.phar'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'myphar.phar'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'exists.txt'</span><span style="color: #007700">] = </span><span style="color: #DD0000">"file exists\n"</span><span style="color: #007700">;<br />try {<br />    </span><span style="color: #FF8000">// automatically calls offsetGet()<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'exists.txt'</span><span style="color: #007700">];<br />    echo </span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'doesnotexist.txt'</span><span style="color: #007700">];<br />} catch (</span><span style="color: #0000BB">BadMethodCallException $e</span><span style="color: #007700">) {<br />    echo </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>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">file exists
Entry doesnotexist.txt does not exist</pre>
</div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-phar.offsetget-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.offsetexists.php" class="function" rel="rdfs-seeAlso">Phar::offsetExists()</a> - Determines whether a file exists in the phar</span></li>
    <li><span class="function"><a href="phar.offsetset.php" class="function" rel="rdfs-seeAlso">Phar::offsetSet()</a> - Set the contents of an internal file to those of an external file</span></li>
    <li><span class="function"><a href="phar.offsetunset.php" class="function" rel="rdfs-seeAlso">Phar::offsetUnset()</a> - Remove a file from a phar</span></li>
   </ul>
  </p>
 </div>


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