<?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 => 'es',
  ),
  'this' => 
  array (
    0 => 'spltempfileobject.construct.php',
    1 => 'SplTempFileObject::__construct',
    2 => 'Construir un nuevo objeto de fichero temporal',
  ),
  'up' => 
  array (
    0 => 'class.spltempfileobject.php',
    1 => 'SplTempFileObject',
  ),
  'prev' => 
  array (
    0 => 'class.spltempfileobject.php',
    1 => 'SplTempFileObject',
  ),
  'next' => 
  array (
    0 => 'ref.spl.php',
    1 => 'Funciones SPL',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    '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">Construir un nuevo objeto de fichero temporal</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-spltempfileobject.construct-description">
  <h3 class="title">Descripción</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">
   Construir un nuevo objeto de fichero temporal.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-spltempfileobject.construct-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">maxMemory</code></dt>
     <dd>
      <p class="para">
       La cantidad máxima de memoria (en bytes, por omisión es 2 MB) para
       el fichero temporal a usar. Su el fichero temporal supera este tamaño,
       Este será movido a un archivo en el directorio temporal del sistema.
      </p>
      <p class="para">
       Si <code class="parameter">maxMemory</code> es negativo, se usará memoria.
       Si <code class="parameter">maxMemory</code> es cero, no se usará memoria.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-spltempfileobject.construct-errors">
  <h3 class="title">Errores/Excepciones</h3>
  <p class="para">
   Lanza una <span class="classname"><a href="class.runtimeexception.php" class="classname">RuntimeException</a></span> si un error ocurre.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-spltempfileobject.construct-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo de <span class="methodname"><strong>SplTempFileObject()</strong></span></strong></p>
    <div class="example-contents"><p>Este ejemplo escribe un fichero temporal en la memoria mientras se puede escribir y leer en este.</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">"Esta es la primera línea\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">"Y esta es la segunda.\n"</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Escrito " </span><span style="color: #007700">. </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">" bytes al fichero temporal.\n\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// Rebobina y lee lo que fué escrito<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>Resultado del ejemplo anterior es similar a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Escrito 47 bytes al fichero temporal.

Esta es la primera línea
Y esta es la segunda.</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-spltempfileobject.construct-seealso">
  <h3 class="title">Ver también</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">PHP input/output streams</a>
     (para <code class="literal">php://temp</code> y <code class="literal">php://memory</code>)
    </li>
   </ul>
  </p>
 </div>


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