<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.spltempfileobject.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'spltempfileobject.construct.php',
    1 => 'SplTempFileObject::__construct',
    2 => 'Construit un nouvel objet repr&eacute;sentant un fichier temporaire',
  ),
  'up' => 
  array (
    0 => 'class.spltempfileobject.php',
    1 => 'SplTempFileObject',
  ),
  'prev' => 
  array (
    0 => 'class.spltempfileobject.php',
    1 => 'SplTempFileObject',
  ),
  'next' => 
  array (
    0 => 'ref.spl.php',
    1 => 'Fonctions SPL',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/spl/spltempfileobject/construct.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="spltempfileobject.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SplTempFileObject::__construct</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.2, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SplTempFileObject::__construct</span> &mdash; <span class="dc-title">Construit un nouvel objet représentant un fichier temporaire</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-spltempfileobject.construct-description">
  <h3 class="title">Description</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SplTempFileObject::__construct</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$maxMemory</code><span class="initializer"> = 2 * 1024 * 1024</span></span>)</div>

  <p class="para rdfs-comment">
   Construit un nouvel objet représentant un fichier temporaire.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-spltempfileobject.construct-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">maxMemory</code></dt>
     <dd>
      <p class="para">
       La mémoire maximale (en octets, par défaut, 2 Mo) à utiliser
       pour le fichier temporaire. Si un fichier temporaire dépasse
       cette taille, il sera déplacé sur le système de fichiers, dans
       le dossier des fichiers temporaires.
      </p>
      <p class="para">
       Si <code class="parameter">maxMemory</code> est négatif, seule la
       mémoire sera utilisée. Si <code class="parameter">maxMemory</code> vaut
       zéro, la mémoire ne sera pas utilisée.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-spltempfileobject.construct-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Lance une exception <span class="classname"><a href="class.runtimeexception.php" class="classname">RuntimeException</a></span>
   si une erreur survient.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-spltempfileobject.construct-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="methodname"><strong>SplTempFileObject()</strong></span></strong></p>
    <div class="example-contents"><p>
     Cet exemple écrit un fichier temporaire en mémoire dans lequel nous allons
     pouvoir écrire et lire des données.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$temp </span><span style="color: #007700">= new </span><span style="color: #0000BB">SplTempFileObject</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$temp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #DD0000">"This is the first line\n"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$temp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">fwrite</span><span style="color: #007700">(</span><span style="color: #DD0000">"And this is the second.\n"</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$temp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ftell</span><span style="color: #007700">() . </span><span style="color: #DD0000">" octets écrits dans le fichier temporaire.\n\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Rewind and read what was written<br /></span><span style="color: #0000BB">$temp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rewind</span><span style="color: #007700">();<br />foreach (</span><span style="color: #0000BB">$temp </span><span style="color: #007700">as </span><span style="color: #0000BB">$line</span><span style="color: #007700">) {<br />    echo </span><span style="color: #0000BB">$line</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus est similaire à :</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">47 octets écrits dans le fichier temporaire.

This is the first line
And this is the second.</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-spltempfileobject.construct-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="classname"><a href="class.splfileobject.php" class="classname">SplFileObject</a></span></li>
    <li>
     <a href="wrappers.php.php" class="link">Flux PHP input/output</a> 
     (pour <code class="literal">php://temp</code> et <code class="literal">php://memory</code>)
    </li>
   </ul>
  </p>
 </div>


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