<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.fpassthru.php',
    1 => 'fpassthru',
    2 => 'Invia tutti i dati rimanenti su un puntartore a file',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Filesystem Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.fopen.php',
    1 => 'fopen',
  ),
  'next' => 
  array (
    0 => 'function.fputcsv.php',
    1 => 'fputcsv',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/filesystem/functions/fpassthru.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.fpassthru" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">fpassthru</h1> 
    <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">fpassthru</span> &mdash; <span class="dc-title">Invia tutti i dati rimanenti su un puntartore a file</span></p>

   </div>
   <div class="refsect1 unknown-598" id="refsect1-function.fpassthru-unknown-598">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>fpassthru</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$handle</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

    <p class="simpara">
     Legge fino a EOF sul puntatore al file dato e scrive i risultati sul buffer di
     output.
    </p>
    <p class="simpara">
     Se si verifica un errore, <span class="function"><strong>fpassthru()</strong></span> restituisce
     <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>. In caso positivo <span class="function"><strong>fpassthru()</strong></span> restituisce
     il numero di caratteri letti da <code class="parameter">handle</code> scritti
     in output.  
    </p>
    <p class="para">Il puntatore al file deve essere valido, e deve puntare ad
un file aperto con successo da <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span> o
<span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span> (e non ancora chiuso da
<span class="function"><a href="function.fclose.php" class="function">fclose()</a></span>).</p>
    <p class="simpara">
     Può essere necessario chiamare<span class="function"><a href="function.rewind.php" class="function">rewind()</a></span> per resettare il puntatore al file all&#039;inizio del file stesso nel caso si abbbia già scritto dai dati nel file. Il file viene chiuso quando si sia chiamata <span class="function"><strong>fpassthru()</strong></span> leggendolo (lasciando<code class="parameter">handle</code> inutilizzato).
    </p>
    <p class="simpara">
     Se desideri semplicemente inviare il contenuto di un file sul buffer di output, 
     senza doverlo modificare o posizionarti in un particolare offset,
     potresti preferire <span class="function"><a href="function.readfile.php" class="function">readfile()</a></span>, che ti salva la
     chiamata a <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>.
    </p>
    <blockquote class="note"><p><strong class="note">Nota</strong>: 
     <p class="para">
      Quando si utilizza <span class="function"><strong>fpassthru()</strong></span> con file binari su sistemi Windows
      si dovrebbe essere certi di aprire il file in modalità binaria
      aggiungendo <code class="literal">b</code> alla modalità utilizzata nella chiamata a
      <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>.
     </p>
     <p class="para">
      Si incoraggia l&#039;uso del flag <code class="literal">b</code> quando si trattano file binari,
      anche se il sistema non lo richiede; in questo modo si rendono gli script
      più trasportabili.
     </p>
    </p></blockquote>
    <p class="para">
    <div class="example" id="example-1">
     <p><strong>Example #1 Utilizzo di  <span class="function"><strong>fpassthru()</strong></span> con file binari</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /> <br /></span><span style="color: #FF8000">// apre il file in modalità binaria<br /></span><span style="color: #0000BB">$name </span><span style="color: #007700">= </span><span style="color: #DD0000">".\public\dev\img\ok.png"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">, </span><span style="color: #DD0000">'rb'</span><span style="color: #007700">);<br /> <br /></span><span style="color: #FF8000">// invia i giusti header<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Type: image/png"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Length: " </span><span style="color: #007700">. </span><span style="color: #0000BB">filesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$name</span><span style="color: #007700">));<br /> <br /></span><span style="color: #FF8000">// invia l'immagine ed esce dallo script<br /></span><span style="color: #0000BB">fpassthru</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />exit;<br /> <br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

     </div>
    </p>
    <p class="simpara">
     Vedere anche <span class="function"><a href="function.readfile.php" class="function">readfile()</a></span>,
     <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>, <span class="function"><a href="function.popen.php" class="function">popen()</a></span> e
     <span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span>
    </p>
   </div>

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