mirror of
https://github.com/php/doc-it.git
synced 2026-03-26 00:22:14 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/it/trunk@314543 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
3.2 KiB
XML
103 lines
3.2 KiB
XML
<?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
|
|
-->
|