<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'phar.setstub.php',
    1 => 'Phar::setStub',
    2 => 'Utilis&eacute; pour sp&eacute;cifier le chargeur PHP ou le conteneur de chargement d\'une archive Phar',
  ),
  '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' => 'fr',
    '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">Utilisé pour spécifier le chargeur PHP ou le conteneur de chargement d&#039;une archive Phar</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-phar.setstub-description">
  <h3 class="title">Description</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">Note</strong>: <p class="para">Cette
    méthode nécessite que la variable de configuration INI <code class="literal">phar.readonly</code>
    soit définie à <code class="literal">0</code> pour fonctionner avec les objets <span class="classname"><a href="class.phar.php" class="classname">Phar</a></span>.
    Sinon, une exception <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span> sera lançée.</p></p></blockquote>


  <p class="para">
   Cette méthode est utilisée pour ajouter un chargeur PHP à une nouvelle archive Phar, ou
   pour remplacer le conteneur de chargement d&#039;une archive Phar existante.
  </p>
  <p class="para">
   Le conteneur de chargement d&#039;une archive Phar est utilisé quand une archive est incluse directement
   comme dans cet exemple :
  </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">'monphar.phar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
  </div>

  <p class="para">
   Le chargeur n&#039;est pas utilisé quand un fichier est inclus via le flux <code class="literal">phar</code>
   comme ceci :
  </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://monphar.phar/unfichier.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">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stub</code></dt>
     <dd>
      <p class="para">
       Une chaîne ou une <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> de flux ouvert à utiliser 
       comme conteneur exécutable pour cette archive phar.
      </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">Valeurs de retour</h3>
  <p class="para">
   Cette fonction retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en cas de succès ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.setstub-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Une exception <span class="classname"><a href="class.unexpectedvalueexception.php" class="classname">UnexpectedValueException</a></span> est levée si
   <a href="phar.configuration.php#ini.phar.readonly" class="link">phar.readonly</a> est activé dans
   le php.ini.
   Une exception <span class="classname"><a href="class.pharexception.php" class="classname">PharException</a></span> est levée si des problèmes sont rencontrés lors de 
   l&#039;écriture des changements sur le disque.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.3.0</td>
      <td>
       Appeler <span class="methodname"><strong>Phar::setStub()</strong></span> avec une
       <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> et une <code class="parameter">length</code>
       est désormais obsolète. De tels appels devraient être remplacés par :
       <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">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Un exemple avec <span class="function"><strong>Phar::setStub()</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: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">) . </span><span style="color: #DD0000">'/nouveau.phar'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #DD0000">'nouveau.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("Salut");'</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("Premier"); Phar::mapPhar("nouveau.phar"); __HALT_COMPILER(); ?&gt;'</span><span style="color: #007700">);<br />    include </span><span style="color: #DD0000">'phar://nouveau.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("Tout le monde");'</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("nouveau.phar"); __HALT_COMPILER(); ?&gt;'</span><span style="color: #007700">);<br />    include </span><span style="color: #DD0000">'phar://nouveau.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">'Erreur lors de l'</span><span style="color: #0000BB">écriture de nouveau</span><span style="color: #007700">.</span><span style="color: #0000BB">phar</span><span style="color: #007700">: </span><span style="color: #DD0000">', $e;<br />}<br />?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(5) &quot;Salut&quot;
string(79) &quot;&lt;?php var_dump(&quot;Premier&quot;); Phar::mapPhar(&quot;nouveau.phar&quot;); __HALT_COMPILER(); ?&gt;&quot;
string(13) &quot;Tout le monde&quot;
string(78) &quot;&lt;?php var_dump(&quot;Second&quot;); Phar::mapPhar(&quot;nouveau.phar&quot;); __HALT_COMPILER(); ?&gt;&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-phar.setstub-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.getstub.php" class="function" rel="rdfs-seeAlso">Phar::getStub()</a> - Retourne le chargeur PHP ou le conteneur de chargement d'une archive Phar</span></li>
    <li><span class="function"><a href="phar.createdefaultstub.php" class="function" rel="rdfs-seeAlso">Phar::createDefaultStub()</a> - Cr&eacute;e un conteneur de chargement d'une archive Phar</span></li>
   </ul>
  </p>
 </div>


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