<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'phar.createdefaultstub.php',
    1 => 'Phar::createDefaultStub',
    2 => 'Create a phar-file format specific stub',
  ),
  'up' => 
  array (
    0 => 'class.phar.php',
    1 => 'Phar',
  ),
  'prev' => 
  array (
    0 => 'phar.count.php',
    1 => 'Phar::count',
  ),
  'next' => 
  array (
    0 => 'phar.decompress.php',
    1 => 'Phar::decompress',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/Phar/createDefaultStub.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phar.createdefaultstub" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::createDefaultStub</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Phar::createDefaultStub</span> &mdash; <span class="dc-title">Create a phar-file format specific stub</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-phar.createdefaultstub-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>Phar::createDefaultStub</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$index</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$webIndex</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>


  <p class="para rdfs-comment">
   This method is intended for creation of phar-file format-specific stubs, and is
   not intended for use with tar- or zip-based phar archives.
  </p>
  <p class="para">
   Phar archives contain a bootstrap loader, or <code class="literal">stub</code>
   written in PHP that is executed when the archive is executed in PHP either via
   include:
   <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>

   or by simple execution:
   <div class="example-contents screen">
    <div class="descriptioncode"><pre class="descriptioncode">php myphar.phar</pre>
</div>
   </div>
  </p>
  <p class="para">
   This method provides a simple and easy method to create a stub that will
   run a startup file from the phar archive.  In addition, different files can
   be specified for running the phar archive from the command line versus through
   a web server.  The loader stub also calls <span class="function"><a href="phar.interceptfilefuncs.php" class="function">Phar::interceptFileFuncs()</a></span>
   to allow easy bundling of a PHP application that accesses the file system.  If the
   phar extension is not present, the loader stub will extract the phar archive
   to a temporary directory and then operate on the files.  A shutdown function
   erases the temporary files on exit.
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-phar.createdefaultstub-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">index</code></dt>
     <dd>
      <p class="para">
       Relative path within the phar archive to run if accessed on the command-line
      </p>
     </dd>
    
    
     <dt><code class="parameter">webIndex</code></dt>
     <dd>
      <p class="para">
       Relative path within the phar archive to run if accessed through a web browser
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-phar.createdefaultstub-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns a string containing the contents of a customized bootstrap loader (stub)
   that allows the created Phar archive to work with or without the Phar extension
   enabled.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.createdefaultstub-errors">
  <h3 class="title">Помилки/виключення</h3>
  <p class="para">
   Throws <span class="classname"><a href="class.unexpectedvalueexception.php" class="classname">UnexpectedValueException</a></span> if either parameter is longer
   than 400 bytes.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-phar.createdefaultstub-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">index</code> and <code class="parameter">webIndex</code> are now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-phar.createdefaultstub-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 A <span class="function"><strong>Phar::createDefaultStub()</strong></span> example</strong></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">try {<br />    </span><span style="color: #0000BB">$phar </span><span style="color: #007700">= new </span><span style="color: #0000BB">Phar</span><span style="color: #007700">(</span><span style="color: #DD0000">'myphar.phar'</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStub</span><span style="color: #007700">(</span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDefaultStub</span><span style="color: #007700">(</span><span style="color: #DD0000">'cli.php'</span><span style="color: #007700">, </span><span style="color: #DD0000">'web/index.php'</span><span style="color: #007700">));<br />} catch (</span><span style="color: #0000BB">Exception $e</span><span style="color: #007700">) {<br />    </span><span style="color: #FF8000">// handle errors<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-phar.createdefaultstub-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.setstub.php" class="function" rel="rdfs-seeAlso">Phar::setStub()</a> - Used to set the PHP loader or bootstrap stub of a Phar archive</span></li>
    <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>
   </ul>
  </p>
 </div>



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