reference/filesystem/functions/fgets.xml
ea62fb83196997032641b50fe44420305466195e
...
...
@@ -9,9 +9,9 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>string</type><methodname>fgets</methodname>
13
-
<methodparam><type>resource</type><parameter>handle</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
12
+
<type class="union"><type>string</type><type>false</type></type><methodname>fgets</methodname>
13
+
<methodparam><type>resource</type><parameter>stream</parameter></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>length</parameter><initializer>&null;</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
Gets a line from file pointer.
...
...
@@ -23,7 +23,7 @@
23
23
<para>
24
24
<variablelist>
25
25
<varlistentry>
26
-
<term><parameter>handle</parameter></term>
26
+
<term><parameter>stream</parameter></term>
27
27
<listitem>
28
28
&fs.validfp.all;
29
29
</listitem>
...
...
@@ -37,14 +37,6 @@
37
37
(whichever comes first). If no length is specified, it will keep
38
38
reading from the stream until it reaches the end of the line.
39
39
</para>
40
-
<note>
41
-
<para>
42
-
Until PHP 4.3.0, omitting it would assume 1024 as the line length.
43
-
If the majority of the lines in the file are all larger than 8KB,
44
-
it is more resource efficient for your script to specify the maximum
45
-
line length.
46
-
</para>
47
-
</note>
48
40
</listitem>
49
41
</varlistentry>
50
42
</variablelist>
...
...
@@ -55,7 +47,7 @@
55
47
&reftitle.returnvalues;
56
48
<para>
57
49
Returns a string of up to <parameter>length</parameter> - 1 bytes read from
58
-
the file pointed to by <parameter>handle</parameter>. If there is no more data
50
+
the file pointed to by <parameter>stream</parameter>. If there is no more data
59
51
to read in the file pointer, then &false; is returned.
60
52
</para>
61
53
<para>
...
...
@@ -63,30 +55,6 @@
63
55
</para>
64
56
</refsect1>
65
57

66
-
<refsect1 role="changelog">
67
-
&reftitle.changelog;
68
-
<para>
69
-
<informaltable>
70
-
<tgroup cols="2">
71
-
<thead>
72
-
<row>
73
-
<entry>&Version;</entry>
74
-
<entry>&Description;</entry>
75
-
</row>
76
-
</thead>
77
-
<tbody>
78
-
<row>
79
-
<entry>4.3.0</entry>
80
-
<entry>
81
-
<function>fgets</function> is now binary safe
82
-
</entry>
83
-
</row>
84
-
</tbody>
85
-
</tgroup>
86
-
</informaltable>
87
-
</para>
88
-
</refsect1>
89
-

90
58
<refsect1 role="examples">
91
59
&reftitle.examples;
92
60
<para>
...
...
@@ -95,15 +63,15 @@
95
63
<programlisting role="php">
96
64
<![CDATA[
97
65
<?php
98
-
$handle = @fopen("/tmp/inputfile.txt", "r");
99
-
if ($handle) {
100
-
while (($buffer = fgets($handle, 4096)) !== false) {
66
+
$fp = @fopen("/tmp/inputfile.txt", "r");
67
+
if ($fp) {
68
+
while (($buffer = fgets($fp, 4096)) !== false) {
101
69
echo $buffer;
102
70
}
103
-
if (!feof($handle)) {
71
+
if (!feof($fp)) {
104
72
echo "Error: unexpected fgets() fail\n";
105
73
}
106
-
fclose($handle);
74
+
fclose($fp);
107
75
}
108
76
?>
109
77
]]>
110
78