reference/filesystem/functions/file-put-contents.xml
ea62fb83196997032641b50fe44420305466195e
...
...
@@ -4,17 +4,17 @@
4
4
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.file-put-contents">
5
5
<refnamediv>
6
6
<refname>file_put_contents</refname>
7
-
<refpurpose>Write a string to a file</refpurpose>
7
+
<refpurpose>Write data to a file</refpurpose>
8
8
</refnamediv>
9
9

10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<methodsynopsis>
13
-
<type>int</type><methodname>file_put_contents</methodname>
13
+
<type class="union"><type>int</type><type>false</type></type><methodname>file_put_contents</methodname>
14
14
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
15
15
<methodparam><type>mixed</type><parameter>data</parameter></methodparam>
16
16
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
17
-
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
17
+
<methodparam choice="opt"><type class="union"><type>resource</type><type>null</type></type><parameter>context</parameter><initializer>&null;</initializer></methodparam>
18
18
</methodsynopsis>
19
19
<para>
20
20
This function is identical to calling <function>fopen</function>,
...
...
@@ -103,36 +103,12 @@
103
103
</entry>
104
104
<entry>
105
105
Acquire an exclusive lock on the file while proceeding to the
106
-
writing.
106
+
writing. In other words, a <function>flock</function> call happens
107
+
between the <function>fopen</function> call and the
108
+
<function>fwrite</function> call. This is not identical to an
109
+
<function>fopen</function> call with mode "x".
107
110
</entry>
108
111
</row>
109
-
<!-- FIXME PHP_6
110
-
<row>
111
-
<entry>
112
-
<constant>FILE_TEXT</constant>
113
-
</entry>
114
-
<entry>
115
-
<parameter>data</parameter> is written in text mode. If unicode
116
-
semantics are enabled, the default encoding is UTF-8.
117
-
You can specify a different encoding by creating a custom context
118
-
or by using the <function>stream_default_encoding</function> to
119
-
change the default. This flag cannot be used with
120
-
<constant>FILE_BINARY</constant>. This flag is only available since
121
-
PHP 6.
122
-
</entry>
123
-
</row>
124
-
<row>
125
-
<entry>
126
-
<constant>FILE_BINARY</constant>
127
-
</entry>
128
-
<entry>
129
-
<parameter>data</parameter> will be written in binary mode. This
130
-
is the default setting and cannot be used with
131
-
<constant>FILE_TEXT</constant>. This flag is only available since
132
-
PHP 6.
133
-
</entry>
134
-
</row>
135
-
-->
136
112
</tbody>
137
113
</tgroup>
138
114
</table>
...
...
@@ -155,7 +131,7 @@
155
131
<refsect1 role="returnvalues">
156
132
&reftitle.returnvalues;
157
133
<para>
158
-
The function returns the number of bytes that were written to the file, or
134
+
This function returns the number of bytes that were written to the file, or
159
135
&false; on failure.
160
136
</para>
161
137
&return.falseproblem;
...
...
@@ -199,47 +175,6 @@ file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
199
175
</para>
200
176
</refsect1>
201
177
202
-
<refsect1 role="changelog">
203
-
&reftitle.changelog;
204
-
<para>
205
-
<informaltable>
206
-
<tgroup cols="2">
207
-
<thead>
208
-
<row>
209
-
<entry>&Version;</entry>
210
-
<entry>&Description;</entry>
211
-
</row>
212
-
</thead>
213
-
<tbody>
214
-
<row>
215
-
<entry>5.0.0</entry>
216
-
<entry>
217
-
Added context support
218
-
</entry>
219
-
</row>
220
-
<row>
221
-
<entry>5.1.0</entry>
222
-
<entry>
223
-
Added support for <constant>LOCK_EX</constant> and the ability to pass
224
-
a stream resource to the <parameter>data</parameter> parameter
225
-
</entry>
226
-
</row>
227
-
<!--
228
-
FIXME PHP_6
229
-
<row>
230
-
<entry>6.0.0</entry>
231
-
<entry>
232
-
Added support for the <constant>FILE_TEXT</constant> and
233
-
<constant>FILE_BINARY</constant> flags
234
-
</entry>
235
-
</row>
236
-
-->
237
-
</tbody>
238
-
</tgroup>
239
-
</informaltable>
240
-
</para>
241
-
</refsect1>
242
-
243
178
<refsect1 role="notes">
244
179
&reftitle.notes;
245
180
&note.bin-safe;
246
181