-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfgets.xml
102 lines (99 loc) · 3.17 KB
/
fgets.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"?>
<!-- EN-Revision: n/a Maintainer: cortesi Status: ready -->
<refentry xml:id="function.fgets" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>fgets</refname>
<refpurpose>Prende una riga da un puntatore a file</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>fgets</methodname>
<methodparam><type>resource</type><parameter>handle</parameter></methodparam>
<methodparam><type>int</type><parameter>length</parameter></methodparam>
</methodsynopsis>
<para>
Restituisce una stringa di <parameter>length</parameter> - 1 byte letti dal file puntato da <parameter>handle</parameter>.
La lettura termina quando sono stati letti <parameter>length</parameter> - 1 byte, oppure si incontra il carattere
di newline (che viene incluso nel valore restituito), oppure alla fine del file
(EOF) qualora giunga prima. Se non si specifica length, si assume
come default 1k, o 1024 byte.
</para>
<para>
Se si verifica un errore, la funzione restituisce &false;.
</para>
<para>
Errori comuni:
</para>
<simpara>
Le persone abituate alla semantica 'C' di fgets notino la differenza
nel trattamento dell'EOF.
</simpara>
&fs.validfp.all;
<para>
Segue un semplice esempio:
<example>
<title>Legge un file riga per riga</title>
<programlisting role="php">
<![CDATA[
<?php
$handle = fopen("/tmp/inputfile.txt", "r");
while (!feof($handle)) {
$buffer = fgets($fd, 4096);
echo $buffer;
}
fclose($handle);
?>
]]>
</programlisting>
</example>
</para>
<note>
<simpara>
Il parametro <parameter>length</parameter> è diventato opzionale a partire da PHP
4.2.0, se omesso, si assume come lunghezza della linea 1024.
A partire dalla versione 4.3, l'omissione del parametro <parameter>length</parameter>
comporta la lettura del flusso d'ingresso sino al raggiungimento della fine della linea.
Se la maggior parte delle righe lette dal file hanno dimensione superiore a 8KB,
è più efficiente specificare la lunghezza massima
della linea.
</simpara>
</note>
<note>
<simpara>
A partire da PHP 4.3 questa funzione è 'binary safe'. Le versioni
precedenti non lo sono.
</simpara>
</note>
¬e.line-endings;
<para>
Vedere anche <function>fread</function>,
<function>fgetc</function>,
<function>stream_get_line</function>,
<function>fopen</function>,
<function>popen</function>,
<function>fsockopen</function> e
<function>stream_set_timeout</function>.
</para>
</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
-->