<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'spltempfileobject.construct.php',
    1 => 'SplTempFileObject::__construct',
    2 => 'Construct a new temporary file object',
  ),
  'up' => 
  array (
    0 => 'class.spltempfileobject.php',
    1 => 'SplTempFileObject',
  ),
  'prev' => 
  array (
    0 => 'class.spltempfileobject.php',
    1 => 'SplTempFileObject',
  ),
  'next' => 
  array (
    0 => 'ref.spl.php',
    1 => 'SPL Funzioni',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    '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">Construct a new temporary file object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-spltempfileobject.construct-description">
  <h3 class="title">Descrizione</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">
   Construct a new temporary file object.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-spltempfileobject.construct-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">maxMemory</code></dt>
     <dd>
      <p class="para">
       The maximum amount of memory (in bytes, default is 2 MB) for 
       the temporary file to use. If the temporary file exceeds this 
       size, it will be moved to a file in the system&#039;s temp directory.
      </p>
      <p class="para">
       If <code class="parameter">maxMemory</code> is negative, only memory
       will be used. If <code class="parameter">maxMemory</code> is zero, 
       no memory will be used.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-spltempfileobject.construct-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <p class="para">
   Throws a <span class="classname"><a href="class.runtimeexception.php" class="classname">RuntimeException</a></span> if an error occurs.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-spltempfileobject.construct-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="methodname"><strong>SplTempFileObject()</strong></span> example</strong></p>
    <div class="example-contents"><p>This example writes a temporary file in memory which can be written to and read from.</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: #DD0000">"Written " </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 to temporary file.\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>Il precedente esempio visualizzerà
qualcosa simile a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Written 47 bytes to temporary file.

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">Vedere anche:</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> 
     (for <code class="literal">php://temp</code> and <code class="literal">php://memory</code>)
    </li>
   </ul>
  </p>
 </div>


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