<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'phar.setstub.php',
    1 => 'Phar::setStub',
    2 => 'Used to set the PHP loader or bootstrap stub of a Phar archive',
  ),
  'up' => 
  array (
    0 => 'class.phar.php',
    1 => 'Phar',
  ),
  'prev' => 
  array (
    0 => 'phar.setsignaturealgorithm.php',
    1 => 'Phar::setSignatureAlgorithm',
  ),
  'next' => 
  array (
    0 => 'phar.startbuffering.php',
    1 => 'Phar::startBuffering',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/Phar/setStub.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phar.setstub" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::setStub</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::setStub</span> &mdash; <span class="dc-title">Used to set the PHP loader or bootstrap stub of a Phar archive</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-phar.setstub-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Phar::setStub</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$stub</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$length</code><span class="initializer"> = -1</span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
 <p class="para">
  Diese Methode des <span class="classname"><a href="class.phar.php" class="classname">Phar</a></span>-Objekts funktioniert nur
  wenn die <var class="filename">php.ini</var>-Einstellung <code class="literal">phar.readonly</code> auf 0
  gesetzt ist, sonst wird eine <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span> geworfen.
 </p>
</p></blockquote>


  <p class="para">
   This method is used to add a PHP bootstrap loader stub to a new Phar archive, or
   to replace the loader stub in an existing Phar archive.
  </p>
  <p class="para">
   The loader stub for a Phar archive is used whenever an archive is included directly
   as in this example:
  </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">include </span><span style="color: #DD0000">'myphar.phar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
  </div>

  <p class="para">
   The loader is not accessed when including a file through the <code class="literal">phar</code>
   stream wrapper like so:
  </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">include </span><span style="color: #DD0000">'phar://myphar.phar/somefile.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
  </div>


 </div>


 <div class="refsect1 parameters" id="refsect1-phar.setstub-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stub</code></dt>
     <dd>
      <p class="para">
       A string or an open stream handle to use as the executable stub for this
       phar archive.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-phar.setstub-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt bei Erfolg <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück. Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.setstub-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   <span class="classname"><a href="class.unexpectedvalueexception.php" class="classname">UnexpectedValueException</a></span> is thrown if
   <a href="phar.configuration.php#ini.phar.readonly" class="link">phar.readonly</a> is enabled
   in php.ini.
   <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span> is thrown if any problems are encountered
   flushing changes to disk.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-phar.setstub-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       Calling <span class="methodname"><strong>Phar::setStub()</strong></span> with a
       <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> and a <code class="parameter">length</code>
       is now deprecated. Such calls should be replaced by:
       <code class="code">$phar-&gt;setStub(stream_get_contents($resource));</code>
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-phar.setstub-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 A <span class="function"><strong>Phar::setStub()</strong></span> example</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: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">) . </span><span style="color: #DD0000">'/brandnewphar.phar'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'brandnewphar.phar'</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'a.php'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'&lt;?php var_dump("Hello");'</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStub</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?&gt;'</span><span style="color: #007700">);<br />    include </span><span style="color: #DD0000">'phar://brandnewphar.phar/a.php'</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getStub</span><span style="color: #007700">());<br />    </span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'b.php'</span><span style="color: #007700">] = </span><span style="color: #DD0000">'&lt;?php var_dump("World");'</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStub</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?&gt;'</span><span style="color: #007700">);<br />    include </span><span style="color: #DD0000">'phar://brandnewphar.phar/b.php'</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getStub</span><span style="color: #007700">());<br />} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'Write operations failed on brandnewphar.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>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(5) &quot;Hello&quot;
string(82) &quot;&lt;?php var_dump(&quot;First&quot;); Phar::mapPhar(&quot;brandnewphar.phar&quot;); __HALT_COMPILER(); ?&gt;&quot;
string(5) &quot;World&quot;
string(83) &quot;&lt;?php var_dump(&quot;Second&quot;); Phar::mapPhar(&quot;brandnewphar.phar&quot;); __HALT_COMPILER(); ?&gt;&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-phar.setstub-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.getstub.php" class="function" rel="rdfs-seeAlso">Phar::getStub()</a> - Return the PHP loader or bootstrap stub of a Phar archive</span></li>
    <li><span class="function"><a href="phar.createdefaultstub.php" class="function" rel="rdfs-seeAlso">Phar::createDefaultStub()</a> - Create a phar-file format specific stub</span></li>
   </ul>
  </p>
 </div>


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