-
Notifications
You must be signed in to change notification settings - Fork 8
/
fpassthru.xml
102 lines (97 loc) · 3.43 KB
/
fpassthru.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?xml version="1.0" encoding="UTF-8"?>
<!-- splitted from ./it/functions/filesystem.xml, last change in rev 1.15 -->
<!-- last change to 'fpassthru' in en/ tree in rev 1.2 -->
<!-- EN-Revision: n/a Maintainer: fernando Status: working -->
<!-- CREDITS: cortesi -->
<!-- OLD-Revision: 1.134/EN.1.2 -->
<refentry xml:id="function.fpassthru" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>fpassthru</refname>
<refpurpose>Invia tutti i dati rimanenti su un puntartore a file</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>int</type><methodname>fpassthru</methodname>
<methodparam><type>resource</type><parameter>handle</parameter></methodparam>
</methodsynopsis>
<simpara>
Legge fino a EOF sul puntatore al file dato e scrive i risultati sul buffer di
output.
</simpara>
<simpara>
Se si verifica un errore, <function>fpassthru</function> restituisce
&false;. In caso positivo <function>fpassthru</function> restituisce
il numero di caratteri letti da <parameter>handle</parameter> scritti
in output.
</simpara>
&fs.validfp.all;
<simpara>
Può essere necessario chiamare<function>rewind</function> per resettare il puntatore al file all'inizio del file stesso nel caso si abbbia già scritto dai dati nel file. Il file viene chiuso quando si sia chiamata <function>fpassthru</function> leggendolo (lasciando<parameter>handle</parameter> inutilizzato).
</simpara>
<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 <function>readfile</function>, che ti salva la
chiamata a <function>fopen</function>.
</simpara>
<note>
<para>
Quando si utilizza <function>fpassthru</function> con file binari su sistemi Windows
si dovrebbe essere certi di aprire il file in modalità binaria
aggiungendo <literal>b</literal> alla modalità utilizzata nella chiamata a
<function>fopen</function>.
</para>
<para>
Si incoraggia l'uso del flag <literal>b</literal> quando si trattano file binari,
anche se il sistema non lo richiede; in questo modo si rendono gli script
più trasportabili.
</para>
</note>
<para>
<example>
<title>Utilizzo di <function>fpassthru</function> con file binari</title>
<programlisting role="php">
<![CDATA[
<?php
// apre il file in modalità binaria
$name = ".\public\dev\img\ok.png";
$fp = fopen($name, 'rb');
// invia i giusti header
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));
// invia l'immagine ed esce dallo script
fpassthru($fp);
exit;
?>
]]>
</programlisting>
</example>
</para>
<simpara>
Vedere anche <function>readfile</function>,
<function>fopen</function>, <function>popen</function> e
<function>fsockopen</function>
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->